Using metadata navigation for both Top Navigation and Quick Launch

cover

SharePoint 2013 introduced managed metadata navigation, which lets you use term sets for navigation. As you probably already discovered, there is no way you can set the metadata navigation for both Top Navigation and Quick Launch because GUI provides only one window to choose a term set to be a provider for your navigation.

You can achieve this through Powershell, though.

Let's create a Managed Metadata Navigation from the scratch and apply it for both Top Navigation and Quick Launch using Powershell:

  1. Create a Managed Metadata Service Application;screenshot
  2. Check the "This service application is the default storage location for column specific term sets." option in Managed Metadata Service Connection properties;2
  3. Open the Term Store Management Tool;3
  4. Create different term sets for Top Navigation and Quick Launch;
  5. Check the "Use this Term Set for Site Navigation" option at Term Sets properties in the "Intended Use" tab;4
  6. Fill your Term Sets with links;
  7. Copy your Term Store, Term Group and Term Sets names;5
  8. Run this script in SharePoint 2013 Management Shell (replace the web URL, Term Store, Term Group and Term Sets names with yours):

    $url = "http://yakovenkosp2013"
    $termStoreName = "Managed Metadata Service"
    $termGroupName = "Site Collection - yakovenkosp2013"
    $topNavigationTermSetName = "Contoso Top Navigation"
    $quickLaunchTermSetName = "Contoso Quick Launch"
    
    
    $web = Get-SPWeb $url
    $site = $web.Site
    $navSettings = New-Object Microsoft.SharePoint.Publishing.Navigation.WebNavigationSettings($web)
    $taxSession = Get-SPTaxonomySession -Site $site
    $termStore = $taxSession.TermStores[$termStoreName]
    $termGroup = $termStore.Groups[$termGroupName]
    
    
    #Global Navigation
    $topNavigationTermSet = $termGroup.TermSets[$topNavigationTermSetName]
    $navSettings.GlobalNavigation.Source = 2
    $navSettings.GlobalNavigation.TermStoreId = $termStore.Id
    $navSettings.GlobalNavigation.TermSetId = $topNavigationTermSet.Id
    
    
    #Quick Launch
    $quickLaunchTermSet = $termGroup.TermSets[$quickLaunchTermSetName]
    $navSettings.CurrentNavigation.Source = 2
    $navSettings.CurrentNavigation.TermStoreId = $termStore.Id
    $navSettings.CurrentNavigation.TermSetId = $quickLaunchTermSet.Id
    
    
    $navSettings.Update()
    

Done! Now you can use this script when you need to set metadata navigation for both Top Navigation and Quick Launch.