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

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

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

  • 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
  • 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
  • will this method work with SharePoint 2013 for consistent global navigation across different site collection?

    Reply
  • 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
  • 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
  • Can i have a link the .aspx pages instead of sub-sites for the submenus?

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

      Reply
  • 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
  • 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
  • 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
  • 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
    • Strange! May be because of caching issues?

      BTW, Is your links pointing to Same Web Application?

      Reply
  • 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
    • 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
  • 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
    • 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
  • 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
  • thanks , but unfortunately it doesn’t work , same issue.

    Reply
  • 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
    • Try this solution: https://www.tcscblog.com/2011/11/21/sharepoint-2010-xml-navigation-with-selected-highlighted-tabs/ (I Haven’t try but!)

      Reply
  • 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
  • This is exactly what I was looking for. Thanks a Bunch!

    Reply
  • 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
    • 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
    • Ah… I see how it works now. Brilliant. Just what I needed for my project. Thanks mate.

      Reply
  • 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
  • hey sorry i given wrong id, now its working perfect. thanks man. u saved my time a lot.

    Reply
  • 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
    • Check the DatasourceID value!

      Reply
  • Yes, This will work for publishing sites as well.

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

    Reply
  • 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
    • 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

Your email address will not be published. Required fields are marked *