How to noindex WordPress search result pages
WordPress search result pages are already noindex: since version 5.7, core prints noindex, follow on every ?s= page through the wp_robots filter, and Hydrogen SEO does the same. Your job is to confirm the tag is there, then decide whether to stop crawlers fetching those URLs at all.
Internal search results are pages built from whatever a visitor typed. They have no fixed content, there is no limit to how many can exist, and anyone can create one by linking to yoursite.com/?s=anything. That is why they should stay out of the index.
Step by step
1. Find both search URL forms
A WordPress search answers at two addresses. The query-string form is https://example.com/?s=coffee. With pretty permalinks, the same results also load at https://example.com/search/coffee/, because core registers rewrite rules for a search base. Any rule you write has to cover both, plus paged results such as /search/coffee/page/2/ and /?s=coffee&paged=2.
2. Check the robots tag on a search page
Search for any word on your site while logged out, view the page source and look for the robots meta tag. Or from a terminal:
curl -s "https://example.com/?s=coffee" | grep -i "name=['\"]robots"
On a default install you should see noindex, follow (core also appends max-image-preview:large). With Hydrogen SEO active the tag reads noindex, follow and nothing else. The plugin applies this as a built-in rule, so there is no switch for it and nobody can turn it off by accident.
3. Fix a search page that is not noindex
If the tag is missing, something removed it. The usual causes:
- A theme whose
header.phpdoes not callwp_head(). No plugin or core tag can print without it. - Code that clears the
wp_robotsfilter without adding search handling back. Search your theme and custom plugins forremove_all_filters( 'wp_robots' )andremove_filter( 'wp_robots', 'wp_robots_noindex_search' ). - A full-page cache serving an old copy. Purge it and test again.
Without an SEO plugin, this restores the behaviour:
add_filter( 'wp_robots', function ( $robots ) {
if ( is_search() ) {
$robots['noindex'] = true;
$robots['follow'] = true;
}
return $robots;
} );
4. Decide whether to block crawling as well
Noindex keeps search pages out of results, but crawlers still fetch them to read the tag. On most sites that is fine. If your server logs or the Search Console Crawl stats report show bots requesting thousands of search URLs, block them in robots.txt instead. Open Hydrogen SEO → Robots.txt Editor and add, inside the User-agent: * group:
Disallow: /?s=
Disallow: /*?s=
Disallow: /search/
Leave /search/ out if you have a real page or category at that path. Understand the trade: a blocked URL is never fetched, so its noindex tag is never read. A blocked search URL that someone links to can still be listed, without a description. Choose robots.txt when crawl volume is the problem and noindex when listings are the problem.
5. Stop linking to search URLs
Crawlers find search URLs through links. Check that your theme, menus and posts do not link to ?s= addresses, for example a "popular searches" widget or tag-like links that run a search. Replace them with links to category or tag archives, which have stable content.
6. Watch for search spam
Spammers sometimes link to a site's search URLs with their own text in the query, hoping the result page gets indexed with that text in its title. With noindex in place those pages cannot be indexed. In Search Console, open Pages, then Excluded by 'noindex' tag, and you may see such URLs listed. That status means the tag is doing its job, and there is nothing to fix.
What about the search feed
Each search also has a feed at /search/coffee/feed/. Hydrogen SEO's Turn off search result feeds switch, under Hydrogen SEO → General → Crawl cleanup, redirects that feed with a 301 to the search results page, and Remove archive and search feed links removes the feed link from the head. Both are off by default. See crawl cleanup for what each switch changes.
Mistakes to avoid
- Adding both noindex and a Disallow, then expecting old listings to drop. Once blocked, Google cannot recrawl the page to see the noindex. Let listed search URLs drop out first, then block.
- Putting search URLs in a sitemap. Neither the core sitemap nor Hydrogen SEO's lists them. If yours does, a custom filter added them.
- Redirecting all searches to the homepage. It breaks the search box for real visitors.
Common questions
Does WordPress noindex search results by default?
Yes. Since WordPress 5.7 the `wp_robots_noindex_search` function adds `noindex, follow` to every search results page on a public site.
Should I block /?s= in robots.txt?
Only if crawlers are spending a lot of requests on search URLs. For most sites the noindex tag alone is enough, and it is the only one of the two that removes a URL from results.
Why does Search Console list my search URLs as excluded?
Because Google crawled them and found the noindex tag. "Excluded by 'noindex' tag" is the expected status for internal search results.