Managed Navigation are the default choice when you create a publishing site in SharePoint 2013 but what do you need to do if you want to rollback programmatically to the old fashion structural navigation ?The Navigation settings for each site are stored within the the property bag of the SPWeb and you can access it through SPWeb.AllProperties[“_webnavigationsettings”] or through SharePoint Manager like showed hereunder
There is a new object WebNavigationSettings from the Microsoft.SharePoint.Publishing.Navigation dll that is responsible for managing (update & persist) the xml settings within the property bag.Application pages like /_layouts/15/AreaNavigationSettings.aspx are adapting their UI based on these settings and by creating a new WebNavigationSettings with the current web as parameter to the constructor.
To rollback to the structural navigation, you can do all required configuration or use the built-in ResetToDefaults() method that will put back the PortalProvider instead of the Taxonomy one.
public void ResetToDefaults()
this.GlobalNavigation.Source = StandardNavigationSource.PortalProvider;
this.CurrentNavigation.Source = StandardNavigationSource.PortalProvider;
this.GlobalNavigation.Source = (this.GlobalNavigation.InheritPortalSettingsFromParent ? StandardNavigationSource.InheritFromParentWeb : StandardNavigationSource.PortalProvider);
this.CurrentNavigation.Source = (this.CurrentNavigation.InheritPortalSettingsFromParent ? StandardNavigationSource.InheritFromParentWeb : StandardNavigationSource.PortalProvider);
this.AddNewPagesToNavigation = true;
this.CreateFriendlyUrlsForNewPages = true;
So in code, once you know it, it’s only a matter of doing
WebNavigationSettings webNavigationSettings = new WebNavigationSettings(rootWeb);
webNavigationSettings.ResetToDefaults(); // will rollback to PortalProvider
if (publishingWeb.Web.Site.CompatibilityLevel >= 15)
And you guess it, that ActivateManagedNavigation will work with the WebNavigationSettings object and adapt it this time to support the Taxonomy Navigation.
So if you’re stapling some feature with some receiver to rollback to the old way of working with navigation (and you should if you’re targeting a SharePoint 2013 Standard License !) make sure that you run after that receiver or execute it through PowerShell once the site is provisioned.