Watch video

*In this chapter, you will take a look at the umbracoNaviHide convention. * 
If you wanted to exclude an item from the iteration, you would use this convention. For instance, you have a very simple site with a navigation. However, if you were to add a new page that you don't want in the navigation, it would still be listed there.

There is a convention in Umbraco that you can use for this purpose: adding a property of type true/false with the alias umbracoNaviHide. ** 
Move to the *Settings *section, and on your text page document type, add a new property called *Hide from Navigation *- make sure the alias is **umbracoNaviHide
, of the type true/false. Add it to your generic properties.

Go to the page of the type Text page, and you should find the Hide from Navigation **property on it. Set this to **Yes.

If you now take a look at your front end, the page is still being displayed, since the code snippet that you are currently using for the navigation is CurrentPage.AncestorOrSelf(1).Children - it is not excluding the pages with the umbracoNaviHide property set to 1 yet.

You will need to add the filter .Where("Visible") in your Razor code. 
Update the code that is outputting the navigation. Add the .Where("Visible") filter. This will basically filter your items and filter out the documents that have the umbracoNaviHide property set to true.

Save your template and go to your front end. The navigation is no longer displaying the page.

Let's review this chapter.

  • *The umbracoNaviHide and Visible is just a convention used to exclude items from an iteration. *

Querying Umbraco data with Razor

Total Time: 00:17:31

Learn how to access and query Umbraco data with Razor so you can write code that outputs navigations, breadcrumbs, sitemaps, lists of items, ...