SharePoint Online: Delete a Link in Quick Launch or Top Navigation using PowerShell

Requirement: Remove a Node from SharePoint Online Top Navigation or Quick Launch bar.

Are you looking to delete a link in your SharePoint Online site’s quick launch or top navigation? Perhaps you have a link that you no longer want to appear in the navigation, or you want to hide a link from users. This blog post will show you how to use PowerShell to remove a link from the quick launch or top navigation in SharePoint Online.

How to Remove Links from SharePoint Online Navigation?

To remove links from SharePoint Online site navigation, follow these steps:

  1. Sign in to your SharePoint Online site as a site owner or administrator.
  2. Click on the “Edit” link at the end of your left navigation or top navigation bar.
    how to edit left navigation in sharepoint online
  3. Hover over the link that you want to remove in the navigation >> Click on the little three dots >> from the context menu, choose “Remove”.
    sharepoint online remove navigation links
  4. Click “Save” to save the changes.

The link should now be removed from the Quick Launch or Top Navigation bar in your modern SharePoint Online site.

Following the steps outlined above, you can easily remove a link from the Quick Launch or Top Navigation in SharePoint Online, giving you greater control over your site’s navigation and organization.

Remove Links from Navigation when Publishing Feature is Active

When the publishing feature is active, things work slightly differently:

  1. Go to Site Settings >> Click on the “Navigation” from Look and feel (You may have to use the “Top link bar” if the publishing feature is not enabled!)
  2. Select the navigation node or link in either global navigation (Top navigation) or from current navigation (Quick Launch)
  3. Click on the “Delete” icon to delete the link from the navigation. 
  4. Click on the “OK” button at the bottom of the page to save your changes.

PowerShell to Delete a Navigation Node in SharePoint Online

Here is the PowerShell to remove a node from quick launch or top 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"

#Remove Link from Navigation
Function Remove-SPONavigationNode()
    Param([Microsoft.SharePoint.Client.NavigationNodeCollection]$Navigation, [String]$NavigationTitle)

    #Iterate through and Remove the Node from Navigation
    For($i = $Navigation.Count - 1; $i -ge 0; $i--)
        If($Navigation[$i].Title -eq $NavigationTitle)
            Write-Host -f Green "Removed " $NavigationTitle 
            #Check in 2nd Level Links
            $ChildLinks = $Navigation[$i].Children

            #Call the function recursively
            If($ChildLinks.Count -gt 0)
                Remove-SPONavigationNode -Navigation $ChildLinks -NavigationTitle $NavigationTitle
#Config Parameters

#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 Top Navigation bar of the web
$TopNavigation = $Ctx.Web.Navigation.TopNavigationBar #For Quick Launch, use: $Ctx.Web.Navigation.QuickLaunch

#Call the function to Remove a Node from navigation
Remove-SPONavigationNode -Navigation $TopNavigation -NavigationTitle "Support Center"

This PowerShell removes given navigation nodes and all its child nodes!

Let’s remove the “Site Contents” link, which points to “/_layouts/15/viewlsts.aspx” from the left navigation in the SharePoint Online site with PnP PowerShell cmdlet Remove-PnPNavigationNode.

#Config Variables
$SiteURL = ""
$LinkTitle = "Site contents"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get Quick Launch Navigation
$NavigationNodeCollection = Get-PnPNavigationNode -Location QuickLaunch

#Get the Link to Delete
$NavigationNode = $NavigationNodeCollection | Where-Object { $_.Title -eq  $LinkTitle}

#Delete Link from left navigation 
Remove-PnPNavigationNode -Identity $NavigationNode.Id -Force

This time, let’s delete the “Home” link from the top navigation bar of a SharePoint Online site.

#Config Variables
$SiteURL = ""
$LinkTitle = "Home"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get the Top Navigation Bar
$NavigationNodeCollection = Get-PnPNavigationNode -Location TopNavigationBar

#Get the Link to Delete
$NavigationNode = $NavigationNodeCollection | Where-Object { $_.Title -eq  $LinkTitle}

#Delete Link from Top navigation 
Remove-PnPNavigationNode -Identity $NavigationNode.Id -Force

To add a new link to the left navigation or top navigation bar, use: How to Add a Link to Quick Launch Navigation in SharePoint Online using PowerShell?

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!

Leave a Reply

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