Consistent Top Navigation Menu across All site collections in SharePoint 2010

Requirement: Display a consistent Top Navigation Menu for across site collections in SharePoint.

We can fulfill this requirement by using custom sitemap providers in SharePoint. Here are the steps at high level

  1. Create your own sitemap file in Layouts folder
  2. Add a Site Map Provider in web.config file
  3. Add a SiteMapDataSource to your master page
  4. change the SharePoint menu’s datasource to your custom SiteMapDataSource

Lets start building SharePoint 2010 common navigation across site collections.

1. Create your own sitemap file in Layouts folder

Modify the site map to match your navigation needs and save it with a .sitemap extension in a location accessible by your SharePoint farm. The _LAYOUTS directory is a great place since any site can get to that location (i.e. _/layouts/BPCorp.sitemap)

Create the sitemap as per the following template code

 <siteMap>
   <siteMapNode title="Container" url="" >
   <siteMapNode title="Global Portal" description="" url="/" />
           <siteMapNode title="Finance" description="" url="~/finance" >
          <siteMapNode title="EMEA" url="~/finance/EMEA" description="" />
            <siteMapNode title="APAC" url="~/finance/APAC" description="" />
            <siteMapNode title="CORP" url="~/finance/CORP" description="" />
         </siteMapNode>
 
        <siteMapNode title="Team" description="" url="~/team" />
        <siteMapNode title="Information Technology" description="" url="~/it" />
        <siteMapNode title="Legal" description="" url="~/legal" />
        <siteMapNode title="Regions" description="" url="" >
            <siteMapNode title="North America" url="~/regions/NA" description=""/>
            <siteMapNode title="Middle East" url="~/regions/me" description=""/>
       </siteMapNode>
   </siteMapNode>
</siteMap>

Site Map control crashes with the error “An unexpected error has occurred.” when you point to a page in the URL (instead of Site) and that site is with broken permissions. Fix is simple: Instead of : , use: =”~/finance/EMEA”>. It also crashes when you have duplicate URLs in the siteMapNode!

2. Add a Site Map Provider in web.config file
Now that you have a site map you will need to add a provider in the web.config of the application that is going to use it. The providers section starts with <providers>. You will need to add a line similar to this.

<add name="BPCorpProvider" siteMapFile="_layouts/BPCorp.sitemap" type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  />

3. Add a SiteMapDataSource to your master page
Next the master page needs to be changed. Edit the Master page you will be using with this site map in SharePoint Designer. You will need to add an asp:SiteMapDataSource right above the SharePoint:AspMenu like the one shown below.

 <asp:SiteMapDataSource ShowStartingNode="False" SiteMapProvider="BPCorpProvider" id="BPCorpSiteMap" runat="server"/>

4. Next you will need to change DataSourceID field in the ASPMenu to match the ID of the SiteMapDataSource as shown below. Make sure you set value for MaximumDynamicDisplayLevels=”3″, otherwise you won’t get sub-menus!

 <SharePoint:AspMenu
      ID="TopNavigationMenuV4"
      Runat="server"
      EnableViewState="false"
      DataSourceID="BPCorpSiteMap"
      AccessKey="<%$Resources:wss,navigation_accesskey%>"
      UseSimpleRendering="true"
      UseSeparateCss="false"
      Orientation="Horizontal"
      StaticDisplayLevels="1"
      MaximumDynamicDisplayLevels="3"  
      SkipLinkText=""
      CssClass="s4-tn" />

Your code will look like this:
sharepoint 2010 consistent navigation across site collections
Save, check in, publish a major version, and approve your master page.

Please note: XML is case sensitive, and you got to replace any special codes like %20 (space) with the literal (i.e. a space). Also there are some special characters for XML like &amp; for &, &lt; for <, and &gt; for >

Finally, Here is what you will get:

sharepoint 2010 common navigation across site collections

Need Security trimming in SharePoint 2010 Top Navigation? Here is my another post: Security Trimmed Top Navigation Menu Using Custom Sitemap Provider for SharePoint

Salaudeen Rajack

Information Technology Professional with Two decades of SharePoint Experience.

37 thoughts on “Consistent Top Navigation Menu across All site collections in SharePoint 2010

  • October 11, 2016 at 11:06 PM

    Can this same functionality be used on SharePoint Foundation 2013? I have a requirement to provide a top-tier navigation component to span across several site collections. I have used a very similar approach with WSS v3 some years back and that spanned 55 site collections without any problems.

    Reply
  • November 24, 2014 at 4:22 PM

    SharePoint 2013 has added Navigation management to its Managed Metadata Term Store. Great news, but it has one limitation: you cannot assign the same navigation across site collections. In other words, a given global navigation node can only be used once. Ridiculous. At least that’s my experience.

    Reply
  • October 14, 2014 at 8:16 PM

    will this method work with SharePoint 2013 for consistent global navigation across different site collection?

    Reply
  • February 6, 2013 at 3:45 PM

    Since we do not want to have sub-sites, can i have site pages as a url instead of sub-site for sub-menus?

    Reply
  • February 6, 2013 at 3:41 PM

    Hello Salaudeen, I have followed the steps mentioned above. The sub menus are appearing next to the top level menu item instead of drop downs. I have checked the .sitemap file and it is correct. Any suggestions?

    Reply
  • February 5, 2013 at 11:11 PM

    Can i have a link the .aspx pages instead of sub-sites for the submenus?

    Reply
    • February 6, 2013 at 4:34 AM

      Sure, will work as long as the subsite inherits permissions from top level site!

      Reply
  • February 5, 2013 at 11:10 PM

    I also have the same problem as mentioned by anonymous. The sub menus are showing up right besides the top level menu item. I verfied that the sub menu items are correctly placed inside top level node.

    Reply
  • February 5, 2013 at 4:45 PM

    Hello, I followed the steps, and it ‘almost’ works correctly. The sub-sitemap nodes are showing up as top level menu items instead of submenu items, so ‘NA’, for example is showing as a top menu item, just like ‘Regions’. Any idea why that might be? I checked the xml tags in the sitemap file and they are correct

    Reply
  • January 29, 2013 at 2:38 PM

    I am getting the same error of sitemapprovider cannot be found. I have added the entry in both web.config files on my two WFEs. I have checked the provider ID and made sure it is correctly referenced in the master page. I have also reset IIS. Something is missing.

    Reply
  • November 26, 2012 at 9:35 PM

    Thank you so much for your article.

    The global navigation works fine when I first load the site but after clicking on any link in the nav bar all the rest of the links then point to a blank page. The a href for each link gets converted to a blank value (a href =””).

    Do you have any suggestions please?

    Reply
    • November 27, 2012 at 9:22 AM

      Strange! May be because of caching issues?

      BTW, Is your links pointing to Same Web Application?

      Reply
  • October 16, 2012 at 11:46 AM

    Hi Salaudeen

    I tried your solution but it does not work for me. May be I am missing something.

    I placed the MyCustomSiteMap.sitemap file in the
    “C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTS” folder of my APP server

    I changed the Web Config of my website ( by browsing to physical location of the config file i.e C:inetpubwwwrootwssVirtualDirectories32995)

    When i edit the master page to add () and change the datasourceid, it comes up with the error
    Error parsing control – The siteMapProvider ‘BPCorpProvider’ cannot be found.

    Can you help please !

    Thanks
    Mandeep

    Reply
    • November 27, 2012 at 9:16 AM

      Mandeep,

      SiteMap File must be placed in WFE(s) and referenced in web.config files of WFE(s). Apparently the error message “The siteMapProvider ‘BPCorpProvider’ cannot be found.” tells you are missing the above steps!

      Regards,
      Sal

      Reply
  • September 11, 2012 at 3:25 PM

    Salaudeen, thanks for putting this together. This solution does work as expected. However, if you enable the publishing features, it breaks. An error comes up, “The DataSourceID of ‘TopNavigationMenuV4’ must be the ID of a control of type IHierarchicalDataSource. A control with ID ‘XXXCustomProvider’ could not be found.” If I deactivate the publishing features, it works again. I suppose I could just deactivate the navigation element of the publishing feature.

    Also, is the only way to view this navigation when on viewlists.aspx, settings.aspx to modify the application.master? If we had to modify this master page, it would affect all web applications on the WFE correct? Any chance you could shed more light on this solution with that respect?

    Thanks again for everything.

    Reply
    • September 12, 2012 at 3:45 PM

      Hi Pete,

      For Application pages, You can either brand the Application.master in Layouts folder or you can attach a HTTP module.

      Please ensure you are packing the changes as a Solution (wsp) and deploying it. Otherwise, it will not be replicated in other WFEs automatically. The error message “A control with ID ‘XXXCustomProvider’ could not be found” occurs when you miss the web.config changes or sitemap datasource id is different in master page.

      Regards,
      Sal

      Reply
  • August 25, 2012 at 2:26 PM

    Hi i need to create a online test for students in Sharepoint 2010 and also store the results in database. I think i should do it by Visual Webpart, but don’t know how please post some material if you can it would be really helpful…Thanks in Advance !!

    Reply
  • August 24, 2012 at 2:59 PM

    thanks , but unfortunately it doesn’t work , same issue.

    Reply
  • August 17, 2012 at 6:14 PM

    how can we make the tabs highlighted when we navigate to other sitecollection, ineed to the tabs to be highlighted based on the location i am

    Reply
    • August 22, 2012 at 12:28 PM

      Try this solution: http://www.tcscblog.com/2011/11/21/sharepoint-2010-xml-navigation-with-selected-highlighted-tabs/ (I Haven’t try but!)

      Reply
  • August 17, 2012 at 6:13 PM

    how can we have highlighted tabs, because when we navigate from one sitecollection to another the tabs are not highlighted.How do we achieve this

    Reply
  • August 6, 2012 at 1:25 PM

    This is exactly what I was looking for. Thanks a Bunch!

    Reply
  • July 15, 2012 at 3:00 AM

    Love your work, thanks for making the effort. Copied everything exactly as you wrote.

    I get Error parsing control – The siteMapProvider ‘BPCorpProvider’ cannot be found. I have the BPCorpProvider in C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14CONFIGweb.config.

    Any ideas how to troubleshoot?

    Reply
    • July 16, 2012 at 11:07 AM

      You have to update the web.config file in your virtual directory! Go to IIS Manager and open your website’s physical location, update the web.config file in that location!

      Reply
    • July 17, 2012 at 3:20 PM

      Ah… I see how it works now. Brilliant. Just what I needed for my project. Thanks mate.

      Reply
  • May 2, 2012 at 12:16 AM

    All of these links are static though, I assume when more pages or sub-sites are added you’ll need to manually modify that sitemap file to include those new links. Is there a way to automate that or have it dynamically updated? Also this doesn’t take any security restrictions into account, or can it?

    Reply
  • April 17, 2012 at 12:18 PM

    hey sorry i given wrong id, now its working perfect. thanks man. u saved my time a lot.

    Reply
  • April 17, 2012 at 3:33 AM

    The DataSourceID of ‘TopNavigationMenuV4’ must be the ID of a control of type IHierarchicalDataSource. A control with ID ‘XXXCustomProvider’ could not be found.

    i got hte above error

    Reply
    • April 17, 2012 at 12:16 PM

      Check the DatasourceID value!

      Reply
  • February 17, 2012 at 6:16 AM

    Yes, This will work for publishing sites as well.

    Reply
  • February 16, 2012 at 6:26 PM

    Thank you for the insight. Do you happen to know if this works for Publishing site collections?

    Reply
  • February 13, 2012 at 7:54 PM

    How can you display your custom master page in application pages; settings.aspx, or viewlsts.aspx, etc.? Do you see multi-level in application pages?

    Thanks

    Reply
    • February 17, 2012 at 6:18 AM

      You have to edit the application.master file with these changes. Additionally to attach the custom application master, you can use http handlers.

      Reply

Leave a Reply