Not sure myself, but I was able to find this :
Changing navigation is another common one since it affects users who can see and how they can act through the hierarchy of sites. The Microsoft.SharePoint.Publishing namespace provides several classes that customize the publishing infrastructure site, such as PublishingWeb and PublishingPage. Using these classes, we can easily change the navigation for each site. If you want a child Web to display as the root level of a site in global navigation, the first turn is inheritance from the parent site, like this:
publishingWeb.InheritGlobalNavigation = false;
You can also hide the entire site pages from global navigation. setting IncludePagesInNavigation - false hides all pages of the site, regardless of the PublishingPage.IncludeInGlobalNavigation property is true
// do not show pages in navigation publishingWeb.IncludePagesInNavigation = false;
If you are dealing with default sites that are not inherited from PublishingWeb, you can still hide these sites from the global navigation bar. For example, if you create a site using the collaboration of the portal template and want to exclude the news site from global navigation, add this site to the __GlobalNavigationExcludes site property:
string globalNavExcludes = String.Empty; SPWeb webSite = MSDNSiteCollection.RootWeb; // _GlobalNavigationExcludes property contains a delimited string of // GUIDs identifying the Id of each site to be excluded from global // navigation if (webSite.AllProperties.ContainsKey("__GlobalNavigationExcludes")) { globalNavExcludes = webSite.AllProperties["__GlobalNavigationExcludes"].ToString(); } SPWeb newsSite = MSDNSiteCollection.AllWebs["News"]; // string is delimited "{GUID};{GUID};", // use format code B to convert to string globalNavExcludes += String.Concat(currentWeb.ID.ToString("B"), ";"); webSite.AllProperties["__GlobalNavigationExcludes"] = globalNavExcludes; webSite.Update();
Adding navigation nodes directly to SPNavigationNodeCollection is a good way to display only those nodes that you want and also to group nodes and links to external sites. Figure 10 shows how to add an internal link, an external link, and a global navigation bar title. This example discusses some of the properties of the SPNavigation class that affect the connection opens in a new window and how to handle empty URLs.
source share