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

Sharepoint customizes navigation feature so that user can navigate to 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 Consulting 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

Softree Consulting is an award-winning SharePoint consultancy that has been working with clients from across the globe to transform workplaces with tools and platforms from Microsoft technology. As a widely recognized organization, we are commonly approached to incorporate technical excellence and innovative design into all our customer actions.....

Site Footer