Making sub-sites inherit managed navigation settings of root site in SharePoint 2013

In SharePoint 2013 when creating sub-sites (at least through the UI), and you set the new sub-site to inherit the global nav from the parent site, and the parent site uses managed navigation, you will find that the global nav of the sub-site does not correctly inherit all the managed navigation links from the parent site.

This has been reported by the links below:

You can fix this by re-applying the navigation settings of the new sub-site after it has been created (as discussed in the first link).

However, when you are provisioning many sites, you may want to fix this by code. Put the code below in a feature receiver and activate the feature for each sub-site:

var web = properties.Feature.Parent as SPWeb;
var rootWeb = web.Site.RootWeb;

var rootWebNavSettings = new WebNavigationSettings(rootWeb);
var thisWebNavSettings = new WebNavigationSettings(web);

thisWebNavSettings.GlobalNavigation.Source = StandardNavigationSource.InheritFromParentWeb;
thisWebNavSettings.GlobalNavigation.TermStoreId = rootWebNavSettings.GlobalNavigation.TermStoreId;
thisWebNavSettings.GlobalNavigation.TermSetId = rootWebNavSettings.GlobalNavigation.TermSetId;

The WebNavigationSettings class is defined in the Microsoft.SharePoint.Publishing.Navigation namespace of the Microsoft.SharePoint.Publishing.dll.


About Bernado

Based in Australia, I am a freelance SharePoint and Dynamics CRM developer. I love developing innovative solutions that address business and everyday problems. Feel free to contact me if you think I can help you with your SharePoint or CRM implementation.
This entry was posted in Managed Navigation, SharePoint 2013. Bookmark the permalink.

2 Responses to Making sub-sites inherit managed navigation settings of root site in SharePoint 2013

  1. tapani says:

    No go with SharePoint 365 since Microsoft.SharePoint.Publishing.Navigation cannot be used.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s