Hide a page from navigation in Umbraco

When developing Umbraco websites there will be many occasions where it’s necessary to write some Razor code to retrieve a collection of pages (published content) that you want to use for creating navigation, site maps etc.

Below is an example of some code that demonstrates this:

@* Select children of current page *@
var collection = CurrentPage.Children.Where("Visible");
@* If any items are returned, render a list *@
if (collection.Any())
    @foreach (var item in collection) {
        <li><a href="@item.Url">@item.Name</a></li>

Sometimes there may be a requirement to create page that you don’t want to appear in the navigation of your site. In the example code the collection that is retrieved is filtered by the “Visible” property which is a boolean value indicating if a page has been set to be visible i.e. to be included in the site navigation.

By design Umbraco doesn’t have a generic property that can be set against content which sets the visible value.

So how is it possible to set the visible value of a page? The standard way of doing this in Umbraco is to add a property to a document type using the umbracoNaviHide property alias.

As it is likely that you would want to use this property for more than one document type it would make sense to create a new document type and use it as a document type composition.

The steps to do this would be as follows:

  1. Login to the Umbraco back office.
  2. Go to the settings section and create a new document type called something like HidePageFromNavigation.
  3. Add a new tab called Custom properties
  4. Add a new property to the tab; give it a name like Hide page? with an alias of umbracoNaviHide and select True/false for its type.
  5. Update any existing document types to use this as a document type composition

Any content that uses a document type with the HidePageFromNavigation composition should now have a Hide page? option that when ticked sets the visible value to false. This will ensure that the content won’t be included in the collection when the visible filter is used in Razor code on a collection of published content.


To be able to comment you need to login using a Google or Facebook account.