SharePoint Online: Hide Search Box in the Top Navigation Suite bar

Requirement: Hide Search Box in the Top Navigation Suite bar in SharePoint Online.

How to Remove Search Box from Top Navigation Suite bar?

If you want to keep your search bar hidden on your SharePoint Online page, there is a way to do that. The search box in SharePoint Online top navigation suite bar can be hidden with this PowerShell script:

#Set Parameters
$SiteURL = "https://Crescent.sharepoint.com/sites/Marketing"

#Get Credentials to connect
$Cred = Get-Credential

Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
 
    #Get Web object
    $Web = $Ctx.Web
    $Ctx.Load($Web)
    $Ctx.ExecuteQuery()

    #Disable search in the navigation bar
    $Web.SearchBoxInNavBar = 3
    $web.Update()
    $Ctx.ExecuteQuery()
}
Catch {
    write-host -f Red "Error:" $_.Exception.Message
}

SearchBoxInNavBar enumeration values:

  • Inherit = 0
  • AllPages = 1
  • ModernOnly = 2
  • Hidden = 3

We can also set search box settings using PnP PowerShell.

#Set Parameters
$SiteURL = "https://Crescent.sharepoint.com/sites/Marketing"

#Connect to SharePoint Online site
Connect-PnPOnline -Url $SiteURL -Interactive

#Hide Searchbox in the Navigation bar
Set-PnPSearchSettings -SearchBoxInNavBar Hidden -Scope Web -Force

This hides the search box from the top navigation bar of the SharePoint Online site in a few minutes. To enable the search box back in the Navigation bar, use:

Set-PnPSearchSettings -SearchBoxInNavBar ModernOnly -Scope Web

Also, you can set the search box visibility at the site collection level by changing the scope parameter from “Web” to “Site”

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: Hide Search Box in the Top Navigation Suite bar

Leave a Reply

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