Can I modify the Global Navigation by using CSOM against a publishing site in SharePoint Online. What I would like to achieve is to hide some of the navigation elements in the global top navigation.


2 Answers 2


See this and this for information on NavigationNodeCollection and NavigationNode respectively. This will need to be changed depending on whether this is done in an app, console app or PowerShell.

using (var context = new ClientContext(url))
    context.Credentials = credentials;

    NavigationNodeCollection qlNodes = context.Web.Navigation.QuickLaunch;

    qlNodes.ToList().ForEach(node => node.DeleteObject());

See SharePointOnlineCredentials to create credentials (if this is in a console app or PowerShell).

  • I have the publishing feature enabled so I don't think that going against web.navigation does help, at least it returned 0 nodes in my case. May 5, 2014 at 11:15
  • 1
    Oh, yeah. You need to use the Microsoft.SharePoint.Client.Publishing namespace then. I found this link on changing the navigation with Publishing (it's JSOM, but it can be done with CSOM with minor edits). However, it seems there are only methods to change the term store, so you'd have to be using Managed Metadata driven navigation.
    – wjervis
    May 5, 2014 at 12:36
  • Yep that seems like the way I'm heading. To bad that we can't handle standard publishing navigation with CSOM but working with navigation has always been quite confusing in SharePoint. May 5, 2014 at 12:58

Use SPNavigation.TopNavigationBar property to manage the nodes in Global Navigation.

Then you could delete navigation nodes as demonstrated below:

using (var ctx = new ClientContext(webUri))
     ctx.Credentials = credentials;
     var topNavBar = ctx.Web.Navigation.TopNavigationBar; //get Global Navigation

     topNavBar.ToList().ForEach(node => node.DeleteObject());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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