How to Change the SharePoint Default Search Text

How to Change the SharePoint Default Search Text (2024)

Last Updated on March 19, 2024

Can you change the search text in SharePoint?

In this guide, you will learn how to modify the search text in SharePoint Online and whether or not it affects the search results.

Let’s get started!

Why change the search text?

First off, in case we’re not on the same page, the search text refers to the placeholder text of the search box.

The default text says “search this site” when on a site and “search in SharePoint” when on the start page.

Search this site on the home page

It also changes when you’re in a document library or a SharePoint list.

Change the search text has two minor benefits:

  • Improves user experience
  • Reflects branding and culture

Since it’s only a placeholder, it’s only as good as making it feel like you own the platform.

It’s a small touch, but it can contribute to a sense of belonging and community among users.

Sign up for exclusive updates, tips, and strategies

    How to Modify the Search Text in SharePoint Online

    What’s cool here is that it isn’t really that hard to implement using the PnP PowerShell module.

    Apply it to a site collection

    If you want to apply it to a specific site collection, you can simply do it in a more direct way.

    Like this:

    # Define the custom search box text
    $SearchBoxText = "Search our site"
    
    # Connect to the specific SharePoint site
    Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive
    
    # Set the custom search box placeholder text for the site
    Set-PnPSearchSettings -SearchBoxPlaceholderText $SearchBoxText
    
    # Disconnect after making changes
    Disconnect-PnPOnline

    For example, in my tenant, I want it to display the name of the site.

    It looks like this now:

    the site search box text in my site is now replaced

    Easy, right? 🙂

    Apply it to all the sites

    But what if you want to apply it to all the SharePoint sites in the tenant?

    Well for that, you can simply do this:

    # Connect to the SharePoint Online Admin Center
    $adminUrl = "https://yourtenant-admin.sharepoint.com"
    Connect-PnPOnline -Url $adminUrl -Interactive
    
    # Define the universal search box text you want to apply across all sites
    $universalSearchBoxText = "Search our SharePoint"
    
    # Retrieve all site collections
    $sites = Get-PnPTenantSite
    
    foreach ($site in $sites) {
        # Connect to each site
        Connect-PnPOnline -Url $site.Url -Interactive
    
        # Set the universal search box placeholder text for the site
        Set-PnPSearchSettings -SearchBoxPlaceholderText $universalSearchBoxText
    
        # Disconnect from the site
        Disconnect-PnPOnline
    }

    The downside to that is that the credential window will pop out for each site since the code will go through each site.

    But it certainly beats having to enter a script for each site, right? 😎

    Now, what if you want to use a parameter that already exists? Like using the site name in the search text?

    Here’s an example of how it can be done:

    # Connect to the SharePoint Online Admin Center
    $adminUrl = "https://yourtenant-admin.sharepoint.com"
    Connect-PnPOnline -Url $adminUrl -Interactive
    
    # Retrieve all site collections
    $sites = Get-PnPTenantSite
    
    foreach ($site in $sites) {
        # Connect to each site
        Connect-PnPOnline -Url $site.Url -Interactive
    
        # Retrieve the site's title
        $web = Get-PnPWeb
        $siteTitle = $web.Title
    
        # Define custom search box text with the site's title
        $SearchBoxText = "Search in $($siteTitle)"
    
        # Set the custom search box placeholder text for the site
        Set-PnPSearchSettings -SearchBoxPlaceholderText $SearchBoxText
    
        # Disconnect from the site
        Disconnect-PnPOnline
    }

    This is derived from the earlier script that I showed you.

    Back to the default search text

    If you want to revert to the default placeholder text, you can simply use an empty string.

    Here’s the script to use:

    Set-PnPSearchSettings -Scope Web -SearchBoxPlaceholderText ""

    Nice and easy. 🙂

    Does it change how search works?

    The search text is mainly aesthetics, so it wouldn’t have any effect on how SharePoint search works.

    It’s literally just a placeholder text for the search box so it wouldn’t give you any custom results.

    Anyway, got any questions on changing the search text in SharePoint Online? Just leave a comment.

    For any business-related questions or concerns, kindly reach out using the contact form here. I’ll reply asap. 🙂

    About Ryan Clark

    As the Modern Workplace Architect at Mr. SharePoint, I help companies of all sizes better leverage Modern Workplace and Digital Process Automation investments. I am also a Microsoft Most Valued Professional (MVP) for M365 Apps & Services.

    Subscribe
    Notify of
    guest
    0 Comments
    Inline Feedbacks
    View all comments
    0
    Would love your thoughts, please comment.x
    ()
    x
    Scroll to Top