Build Options

The `UmbNavBuildOptions` class controls how the Menu Builder Service processes menu items. Use build options to filter, transform, and limit the menu data at render time.

Class Definition

namespace Umbraco.Community.UmbNav.Core.Models;

public class UmbNavBuildOptions
{
    public bool RemoveNoopener { get; set; }
    public bool RemoveNoreferrer { get; set; }
    public bool HideIncludeChildren { get; set; }
    public bool RemoveDescription { get; set; }
    public bool RemoveCustomClasses { get; set; }
    public bool RemoveImages { get; set; }
    public int MaxDepth { get; set; }

    public static UmbNavBuildOptions Default => new();
}

Options Reference

RemoveNoopener

Type: bool Default: false

When true, sets the Noopener property to null on all items. Use this to strip rel="noopener" from rendered links.

Before:

After:

RemoveNoreferrer

Type: bool Default: false

When true, sets the Noreferrer property to null on all items. Use this to strip rel="noreferrer" from rendered links.

HideIncludeChildren

Type: bool Default: false

When true, prevents the automatic inclusion of child content nodes even if the editor enabled "Include Child Nodes" on an item.

RemoveDescription

Type: bool Default: false

When true, sets the Description property to null on all items. Use this when descriptions aren't needed in a particular view.

RemoveCustomClasses

Type: bool Default: false

When true, sets the CustomClasses property to null on all items. Use this when you don't want editor-defined classes in the output.

RemoveImages

Type: bool Default: false

When true, sets both Image and ImageArray properties to null on all items. Use this when images aren't needed.

MaxDepth

Type: int Default: 0

Controls the maximum depth of menu items to include:

  • 0 = Unlimited (include all levels)

  • 1 = Root items only (no children)

  • 2 = Root + one level of children

  • 3 = Root + two levels of children

  • etc.

Usage Examples

Basic Usage

Default Options

Use default options explicitly:

Header Navigation

Simplified navigation for the header:

Simple footer links:

Mega Menu

Full-featured mega menu:

API Response

Minimal data for JSON API:

Ensure external links always have security attributes:

Configuration vs Build Options

Understanding when to use Data Type configuration vs Build Options:

Scenario
Data Type Config
Build Options

Feature availability

Editor experience

Per-property settings

Per-view settings

Runtime overrides

API transformations

Example: Different Views, Same Data

Combining Options

All options can be combined:

Object Initializer Syntax

Create options inline:

Immutability Note

UmbNavBuildOptions is a mutable class. If you reuse options, be aware that changes affect all usages:

Testing with Options

Options are useful in unit tests for controlling input:

See Unit Tests for more examples.

Last updated

Was this helpful?