Show subsite on top navigation

Showing subsite programmatically is not as straight forward as using the UI

Global navigation

I found out that this property is only available from PublishingWeb (instead of SPWeb object) which is contained in Microsoft.Sharepoint.Publishing.dll. By default VS 2010 does not include the dll in the reference. After adding the dll, use the code below to show sub sites

PublishingWeb publisher = PublishingWeb.GetPublishingWeb(myWeb);
                        
publisher.Navigation.GlobalIncludeSubSites = true;
publisher.Update();
publisher.Close();

            

Hope that helps