How to add node to Structural Navigation CSOM?

I don't use taxonomy, i don't use automatically added pages or lists.

I end up on determining, that global navigation is StandardNavigationSource.PortalProvider . And i searched google, stackexchange, MSDN and PnP to find some example how to programatically modify nodes and come up with nothing :(

Maybe it can be done using web.Navigation.TopNavigationBar, but that contains different nodes than ones defined in structure and displayed in sharepoint :(

UPDATE: I tried modifying TopNavigationBar like this

NavigationNodeCreationInformation node = new NavigationNodeCreationInformation();
            node.Title = "test program";
            node.Url = "http://test3";
            node.IsExternal = true;
            node.AsLastNode = true;
            NavigationNode nodeAdded = parentNode.Children.Add(node);


And it worked, but still TopNavigationBar collections contains nodes that are not displayed in Sharepoint or in structure navigation settings. How do i found out those nodes so i can ignore it when copying navigation?

Update 2: Well it added node with that code once, than i experimented with external urls etc. and i'm not able to add more nodes!

Update 3: After some more experimenting it seems to ignore HTTPS URLs, that is quite crazy, and also ignore relative URLs.

Update 4: So adding node with absolute path with https at start and then changing it to https in the update works.

I Still don't know how to determine which nodes are actually shown in global top navigation and which don't show programmatically.

1 Answer 1


So after debugging and experimenting i found out that only nodes that have IsExternal = true are shown in global navi, however you can't simply set that parameter. You need to add some external http link and then changing it to whatever you need to make it show in global navi.

Sharepoint even converts it to relative link while keeping IsExternal = true.

Very very confusing and not documented AFAIK.

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.