SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add custom link to topnavigation bar, this link will be common through out sitecollections and it should appear as the first link in navigation bar. I have used following code to add my custom link but it is showing in second position of the top nav bar. Is there any way that i could appear at first position.

 public class MyCustomSiteMapProvider : PortalSiteMapProvider
    public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
            PortalSiteMapNode pNode = node as PortalSiteMapNode;
            if (pNode != null)
                string homeUrl = GetMyHomeUrl();
                if (pNode.Type == NodeTypes.Area && pNode.WebId == SPContext.Current.Site.RootWeb.ID)
                    SiteMapNodeCollection nodeColl = base.GetChildNodes(pNode);
                    SiteMapNode homeNode = new SiteMapNode(this,
                                                            "<" + homeUrl + ">", "" + homeUrl + "",
                                                            "My Home");

                    nodeColl.Insert(0, homeNode);
                    base.CurrentNode.Title = "MY Home";

                    return nodeColl;
                return base.GetChildNodes(pNode);
            return new SiteMapNodeCollection();
share|improve this question
Is the Publishing Infrastructure feature active on your site collection? In my experience, sites with the Publishing Infrastructure (site collection level) and Publishing (site level) features activated automatically add a navigation link (to the default page of the site) as the first link/node in the top navigation bar, and this link/node is inaccessible through code or through the Global Navigation group in AreaNavigationSettings. If anyone has an answer of how to access that node, I'd be interested to hear it. – Dylan Cristy Apr 9 '13 at 16:31

First get the SiteMapNodes from the collection, then call .Clear(), add yours first and then add the rest of them back.

Check this to see how they moved node items around:

share|improve this answer

Why not use the OOTB Portal Site Connection setting? It will add your main site collection to the top of the bread crumb. See how to reactivate it here.

Otherwise, you may need to add that link manually to the first page in your sub-site collections. To that end, you could create a powershell script to do it. Hints on that here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.