Language עב
search

Prevent Search Engines from Indexing WordPress Search Result pages

It is possible and advisable (in most cases) to prevent search engines from indexing search results pages on your WordPress site. These pages offer no unique value to searchers and their indexation wastes crawl budget that could be spent on more important pages.

If left unchecked, search result URLs can also appear in your Google Search Console Index Report as indexed pages, cluttering your data with low-value URLs.

robots.txt vs noindex: Which One to Use?

There are two common approaches to blocking search results pages, and it is important to understand the difference between them.

robots.txt Disallow – prevents search engines from crawling the URL. However, it does not prevent indexing. If Google finds a link to a disallowed URL on another page, it may still index that URL – often displaying it in search results with a message like “A description for this result is not available because of this site’s robots.txt.”

noindex meta tag – tells search engines not to index the page. This is the definitive way to keep a page out of search results, but it requires the page to be crawlable so the bot can read the tag.

For WordPress search result pages, using robots.txt Disallow is the practical choice. These pages are rarely linked from external sites, so the risk of them being indexed despite the disallow rule is very low. Yoast SEO and Rank Math both use this approach.

Block Search Results with robots.txt

Add the following directives to your robots.txt file, located in the root directory of your site. This assumes you have not modified the default WordPress search URL structure:

User-agent: *
Disallow: /?s=
Disallow: /search/

The first rule blocks the default WordPress search URL format (/?s=query). The second blocks the “pretty” search URL format (/search/query) that some themes or plugins use.

Block Search Results with Yoast SEO

If you are using Yoast SEO, you can do this through the WordPress dashboard without editing files. Go to Yoast SEO > Settings > Advanced > Crawl optimization.

Under the “Internal site search cleanup” section, enable “Prevent crawling of internal site search URLs“. Yoast will automatically add the necessary Disallow rules to your virtual robots.txt file.

Yoast SEO crawl optimization - prevent crawling of internal site search URLs

Yoast also offers additional options in this section: filtering spam search terms and redirecting “pretty” search URLs to their raw format. Both help protect your site from SEO spam attacks that exploit internal search to create spammy indexed URLs.

Add noindex as an Extra Layer (Optional)

For maximum protection, you can add a noindex meta tag to search result pages alongside the robots.txt rule. Add this to your theme’s functions.php:

add_action( 'wp_head', function() {
    if ( is_search() ) {
        echo '<meta name="robots" content="noindex, nofollow">';
    }
} );

This ensures that even if a search result page is crawled (for example, before you added the robots.txt rule), it will still carry a noindex directive.

FAQs

Common questions about blocking WordPress search results from indexing:

Does robots.txt Disallow actually prevent indexing?
No. Disallow in robots.txt prevents crawling, not indexing. If Google finds a link to a disallowed URL elsewhere, it can still index the URL without crawling it. For WordPress search results, this is rarely an issue since these pages are almost never linked externally. For guaranteed removal from search results, use a noindex meta tag.
Will blocking search results pages affect my site's SEO?
It will improve it. Search result pages are low-value, dynamically generated pages. Blocking them from being crawled saves crawl budget for your actual content - posts, pages, and product pages. It also keeps your Google Search Console reports cleaner.
Do I need both robots.txt and noindex for search result pages?
No. For most sites, the robots.txt Disallow rule is sufficient. Adding a noindex meta tag is an optional extra layer of protection. Note that if you block a URL via robots.txt and also add noindex, search engines may not see the noindex tag since they cannot crawl the page. In practice, using one method consistently is enough.
Does Rank Math have a similar setting to block search results?
Yes. In Rank Math, go to Rank Math > General Settings > Edit robots.txt and add the same Disallow rules. Rank Math also lets you set noindex on search pages by default under Titles & Meta > Misc Pages > Search Results.
What happens to search result pages that are already indexed?
After adding the Disallow rule, Google will stop crawling those URLs. Already-indexed pages will gradually drop out of the index over time. To speed up removal, use the URL Removal Tool in Google Search Console or add a noindex meta tag (which requires temporarily removing the Disallow rule so Google can crawl and read the tag).

Summary

WordPress search result pages should not be indexed by search engines. The simplest solution is adding Disallow: /?s= and Disallow: /search/ to your robots.txt file, or enabling the Crawl Optimization setting in Yoast SEO. For an extra layer of protection, add a noindex meta tag via functions.php.

Join the Discussion
0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo