How to create structural navigation nodes both in quick launch and top navigation node

Sharepoint customizes navigation feature so that user can navigate to a different location and access them quickly. You can add, edit, or remove links on the left-hand menu (Quick Launch menu), the top menu (Top Navigation Node) through edit links.

In this blog, we are going to create structural navigation node that is root node having subnodes in both top navigation and quick launch.

using System;
using System.Linq;
using System.Security;
using Microsoft.SharePoint.Client;
namespace StructuralNavigationNode
class Program
static void Main(string[] args)
ClientContext ctx = new ClientContext("http://portal/sites/site1");
string password = "Password";
SecureString secureString = new SecureString();
foreach (char c in password.ToCharArray()) secureString.AppendChar(c);
ctx.Credentials = new SharePointOnlineCredentials("", secureString);
Web web = ctx.Web;

NavigationNodeCollection quickLaunchNodeColl = web.Navigation.QuickLaunch; // we are getting all quick launch node collection
NavigationNodeCollection topNavNodeColl = web.Navigation.TopNavigationBar; // we are getting all top navigation node collection

NavigationNodeCreationInformation quickLaunchNodeCreation = new NavigationNodeCreationInformation();
quickLaunchNodeCreation.Title = "QuickLaunchNode";
quickLaunchNodeCreation.Url = "";
quickLaunchNodeColl.Add(quickLaunchNodeCreation); //we are creating root quick launch node

NavigationNode quickLaunchParentNode = quickLaunchNodeColl.Where(n => n.Title == "QuickLaunchNode").FirstOrDefault(); //retrieving parent quick launch root node for which we will add sub nodes
NavigationNodeCreationInformation quickLaunchNodeCreationInformation = new NavigationNodeCreationInformation();
quickLaunchNodeCreationInformation.Title = "QuickLaunchSubNode";
quickLaunchNodeCreationInformation.Url = "";
quickLaunchParentNode.Children.Add(quickLaunchNodeCreationInformation); //we are creating sub quicklaunch node

NavigationNodeCreationInformation topNavNodeCreation = new NavigationNodeCreationInformation();
topNavNodeCreation.Title = "TopNavNode";
topNavNodeCreation.Url = "";
topNavNodeColl.Add(topNavNodeCreation); //we are creating root top navigation node

NavigationNode topNavParentNode = topNavNodeColl.Where(n => n.Title == "TopNavNode").FirstOrDefault(); //retrieving parent top navigation root node for which we will add sub nodes
NavigationNodeCreationInformation topNavNodeCreationInformation = new NavigationNodeCreationInformation();
topNavNodeCreationInformation.Title = "TopNavSubNode";
topNavNodeCreationInformation.Url = "";
topNavParentNode.Children.Add(topNavNodeCreationInformation); //we are creating sub top navigation node



After code executed, you can see root navigation with their respective subnodes created successfully.

This solution is brought to you by our SharePoint professionals.

Softree Technology employs SharePoint consultants; we are a technology services provider with the aim to help companies achieve exceptional performance through SharePoint. Our dedicated team of SharePoint consultants has the right bent of mind to understand and execute customer requirements.

Be it SPFx or SharePoint add-in developments, SharePoint 2019 developments, web part developments, migrating from SharePoint 2010/2013 to SharePoint 2013/2016/Office 365, Office 365, SharePoint hosted apps development or something else in SharePoint, we strive to deliver the best

Previous Post
Next Post

Leave a Reply

Your email address will not be published. Required fields are marked *