SharePoint Online: Add Link to Quick Launch Navigation using PowerShell

Requirement: Add Link to Quick Launch Navigation SharePoint Online using PowerShell.

The Quick Launch bar is located on the left side of the page. At times, you may want to add new links to it. This blog post will show you how to add a link to the Quick Launch navigation in SharePoint Online. We will also show you how to use PowerShell to add a link to the Quick Launch navigation bar in SharePoint Online.

To add a link to quick launch navigation in modern SharePoint sites, follow these steps:

  1. Click on the “Edit” link at the bottom of the left navigation menu. (If you don’t see the “Edit” link, you may not have permission to edit quick launch!)
    sharepoint online add link to quick launch
  2. Hover over the quick launch menu and click on the “+” icon where you want to add a link.
  3. On the “Add a link” dialog box, Enter the URL and display name for the link. Click on OK once done!
    sharepoint online add to quick launch
  4. Click on the “Save” button at the bottom of the page to save your changes.

That’s it! The new link should now appear in the Quick Launch on your SharePoint Online site.

Add a link to the left navigation in Classic sites

To add a link in quick launch navigation in classic SharePoint Online sites, do the following:

  1. Go to Site Settings >> Click on “Quick launch” from Look and feel
  2. From the Quick Launch page, You can add a new heading or link by clicking relevant links.
    powershell to add link to quick launch navigation in sharepoint online

If the publishing feature is enabled, You’ll get the “Navigation” link in the site settings.

PowerShell is a powerful tool that allows administrators to automate tasks and customize system settings. Let me show you how to use PowerShell to add a link to the Quick Launch navigation in SharePoint Online.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
   
#Config Parameters
$SiteURL="https://Crescent.sharepoint.com/sites/marketing"

#Setup Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials

#Get the Quick launch Navigation of the web 
$QuickLaunch = $Ctx.Web.Navigation.QuickLaunch
$Ctx.load($QuickLaunch)
$Ctx.ExecuteQuery()

#Add link to Quick Launch Navigation
$NavigationNode = New-Object Microsoft.SharePoint.Client.NavigationNodeCreationInformation
$NavigationNode.Title = "Support Center"
$NavigationNode.Url = "https://support.crescent.com"
$NavigationNode.AsLastNode = $True
$Ctx.Load($QuickLaunch.Add($NavigationNode))
$Ctx.ExecuteQuery() 

Let’s add some more functionality to the script so that we can add a link to any specific node:

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Add new Link in Quicklaunch Navigation
Function Add-SPONavigationNode()
{
    Param(
        [Microsoft.SharePoint.Client.NavigationNodeCollection]$Navigation,
        [parameter(Mandatory=$false)][String]$ParentNodeTitle,
        [String]$Title,
        [String]$URL
    )
    #Populate New node data
    $NavigationNode = New-Object Microsoft.SharePoint.Client.NavigationNodeCreationInformation 
    $NavigationNode.Title = $Title
    $NavigationNode.Url = $URL
    $NavigationNode.AsLastNode = $true

    #Get the Parent Node
    $ParentNode = $Navigation | Where-Object {$_.Title -eq $ParentNodeTitle}
    
    #Add New node to the navigation
    If($ParentNode -eq $null)
    {
        #Check if the Link with Title exists already
        $Node = $Navigation | Where-Object {$_.Title -eq $Title}
        If($Node -eq $Null)
        { 
            #Add Link to Root node of the Navigation
            $Ctx.Load($Navigation.Add($NavigationNode))
            $Ctx.ExecuteQuery()
            Write-Host -f Green "New Navigation Node '$Title' Added to the Navigation Root!"
        }
        Else
        {
            Write-Host -f Yellow "Navigation Node '$Title' Already Exists in Root!"
        }
    }
    else
    {
        #Get the Parent Node
        $Ctx.Load($ParentNode)
        $Ctx.Load($ParentNode.Children)
        $Ctx.ExecuteQuery()
 
        $Node = $ParentNode.Children | Where-Object {$_.Title -eq $Title}
        If($Node -eq $Null)
        { 
            #Add Link to Parent Node
            $Ctx.Load($ParentNode.Children.Add($NavigationNode))
            $Ctx.ExecuteQuery()
            Write-Host -f Green "New Navigation Link '$Title' Added to the Parent '$ParentNodeTitle'!"
        }
        Else
        {
            Write-Host -f Yellow "Navigation Node '$Title' Already Exists in Parnet Node '$ParentNodeTitle'!"
        }
    }
}
 
#Config Parameters
$SiteURL="https://Crescent.sharepoint.com/unitedstates"

#Setup Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials

#Get the Quick Launch Navigation of the web
$QuickLaunch = $Ctx.Web.Navigation.QuickLaunch
$Ctx.load($QuickLaunch)
$Ctx.ExecuteQuery()

#Call the function to Add a New Node in Root of the navigation
Add-SPONavigationNode -Navigation $QuickLaunch -Title "Support Center" -URL "https://support.crescent.com"

#Call the function to Add a link in "Support Center" node of the navigation
Add-SPONavigationNode -Navigation $QuickLaunch -ParentNodeTitle "Support Center" -Title "Application Support" -URL "https://suppport.crescent.com/apps"

If you want to add a link to the Quick Launch navigation bar, the PnP PowerShell cmdlet Add-PnPNavigationNode can help!

#Config Variables
$SiteURL = "https://crescent.sharepoint.com/us"

#Get Credentials to connect
$Cred = Get-Credential

Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Credentials $Cred
    
    #Add a Link to Quick Launch Navigation
    Add-PnPNavigationNode -Title "Support Center" -Url "https://support.crescent.com" -Location "QuickLaunch"

    #Get the Navigation node "Support Center"
    $ParentID = Get-PnPNavigationNode -Location QuickLaunch | Where {$_.Title -eq "Support Center"}  | Select -ExpandProperty ID
    #Add a link under "Support Center
    Add-PnPNavigationNode -Title "Application Support" -Url "https://support.crescent.com/apps" -Location "QuickLaunch" -Parent $ParentID
 
    Write-host "Quick Launch Links Added Successfully!" -f Green
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}

To remove a link from the navigation, use: How to Remove a Link in Quick Launch or Top Navigation in SharePoint Online using PowerShell?

How do I add a document library to site navigation?

Navigate to SharePoint Online Document Library >> Click on Settings >> Document Library Settings. Click on the “List name, description and navigation” link under “General Settings” and set “Yes” for “Display this document library on the Quick Launch?” and then hit the save button. You can also use PowerShell to set the “OnQuickLaunch” property to add the SharePoint Online document library to the site navigation.
More info: SharePoint Online Add Document Library to Quick Launch

How to hide site contents in SharePoint Online?

Navigate to your SharePoint Online site >> Click on the “Edit” link under the quick launch navigation >> Click on the little three dots next to the “Site contents” menu item to get its context menu. Select “Remove” from the context menu >> Click on the Save button to hide site contents from the quick launch.
More info: SharePoint Online: Hide “Site Contents” from Quick Launch

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

2 thoughts on “SharePoint Online: Add Link to Quick Launch Navigation using PowerShell

  • How can this be done programatically with C#?

    Reply
  • Can you just rearrange the items that are there?

    Reply

Leave a Reply

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