I want to add a page to my site definition which is hidden ie. doesn't appear in the navigation, by default.

The page is provisioned in the onet.xml file as follows;

<File Url="SomePage.aspx" Type="GhostableInLibrary" Path="default.aspx">
    <Property Name="Hidden" Value="TRUE" />
    <Property Name="Title" Value="Some Page" />
    <Property Name="ContentType" Value="$Resources:cmscore,contenttype_welcomepage_name;" />
    <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/pagelayouts/mypagelayout.aspx, My Page Layout" />            

As you can see I have tried setting a property of Hidden but this seems to have no effect. Is there any way to set the page to be created in the site but not shown int he navigation. I have relatively limited experience with site definitions so am probably approaching it wrong?

UPDATE: I decided to approach this a different way and "simply" hide the navigation item in a feature event receiver run when the site is provisioned. However this turns out to be far from simple.

At first I tried to access the Navigation of the SPWeb


But this is a null reference. So I created a PublishingWeb from the web and looked in there

PublishingWeb pw = PublishingWeb.GetPublishingWeb((SPWeb)properties.Feature.Parent);

But this is also a null reference. Some searching on Google turned up this article - http://blog.mastykarz.nl/programmatically-configuring-menu-items-sharepoint-2010/ - which explains that the navigation is not populated until it is first updated through the UI and provides a fairly low level powershell solution to populate this navigation by creating a fake SPContext, grabbing a PortalSiteMapProvider and getting the navigation from there. I rewrote this into my feature receiver and have code looking like this:

        SPWeb web = (SPWeb) properties.Feature.Parent;
        PublishingWeb pw = PublishingWeb.GetPublishingWeb((SPWeb)properties.Feature.Parent);

        HttpRequest request =  new HttpRequest("", web.Url, "");
        StringWriter sw = new StringWriter();
        HttpResponse response = new HttpResponse(sw);
        HttpContext.Current = new HttpContext(request, response);
        SPControl.SetContextWeb(HttpContext.Current, web);

        ProviderSettings ps = new ProviderSettings("CombinedNavSiteMapProvider", "Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
        ps.Parameters["NavigationType"] = "Combined";
        ps.Parameters["EncodeOutput"] = "true";
        PortalSiteMapProvider psmp = (PortalSiteMapProvider) ProvidersHelper.InstantiateProvider(ps, typeof(Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider));
        PortalSiteMapNode current = (PortalSiteMapNode) psmp.CurrentNode;
        SiteMapNodeCollection nodes = current.GetNavigationChildren(NodeTypes.Default, NodeTypes.Default, OrderingMethod.Manual, AutomaticSortingMethod.Title, true, -1);

Alas the nodes collection is empty. I have tried using the GlobalNavSiteMapProvider and the CombinedNavSiteMapProvider with the same results. However when the receiver finishes the site does indeed have navigation items.

This seems like such a basic requirement that nearly every SharePoint development would need; some deployable control of navigation.

Is this really the way we are supposed to do this? Is there not a simple solution? And if it is the recommended way does anybody know why the nodes collections are always empty for me?

  • What is the purpose of your page? Does it have to be in a page library? Can the page be customized by some privileged users?
    – Steve B
    Commented Jul 2, 2012 at 13:50
  • It is in effect, although a simplification, a 'results' page, however the results are displayed by a web part and there is other content on the page which can be customized by content editors, administrators etc. The page should only be reached by 'searching' as without context it is useless, but is a publishing page with workflow for content updates too. Commented Jul 3, 2012 at 8:45

2 Answers 2


Provision the file not to a doc library but to a folder (or even to the root folder of the site, where default.aspx lives). It will be all but invisible from the web interface(unless you create a nav link), however it will be visible to site admins via SharePoint Designer(if they know where to look).

  • The site, or at least the web containing the page in question, is public internet and the page should be accessible to anonymous users. However we naturally want anonymous access restricted to a limited number of lists/libraries. If I put the page in a folder, won't this mean that I can't make it accessible to anonymous users? What I really want is a solution to adding it to a library, but without adding it to the navigation. Commented Jul 3, 2012 at 9:09

After revisiting this problem several times and wasting much time on trying to find a resolution I have resorted to a small piece of custom Javascript which updates the menu on page load to hide and add items as required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.