How to fix search results indexable on Next.js (Headless)

Add a noindex robots meta tag to all internal search result pages and block the search URL path in robots.txt to prevent Google from crawling and indexing thin, duplicate search results.

Steps for Next.js (Headless)

  1. Identify your search results route. In the App Router it is typically `app/search/page.tsx` (or `app/search/[query]/page.tsx`); in the Pages Router it is `pages/search.tsx` (or `pages/search/[query].tsx`).
  2. App Router: Export a `generateMetadata` function from the search page that returns `robots: { index: false, follow: false }`. This renders `<meta name='robots' content='noindex,nofollow'>` automatically. Pages Router: Use `next/head` to inject `<meta name='robots' content='noindex,nofollow'>` inside the page component.
  3. Create or edit `public/robots.txt` (the static file served at `/robots.txt`) and add a `Disallow: /search` rule under the `User-agent: *` block to stop crawlers from even requesting the URL.
  4. If search is served from multiple paths (e.g. `/search`, `/catalogsearch/result`, `/s`), add a `Disallow` line for each path and mirror a `noindex` tag in every corresponding page file.
  5. Deploy and verify with Google Search Console's URL Inspection tool that the page returns `noindex` in the HTTP response and that Googlebot obeys the `robots.txt` disallow rule.
Official Next.js (Headless) documentation ↗

What is search results indexable?

When a visitor searches your store, the results appear on a dynamically generated URL — for example, `/search?q=red+shoes` or `/search-jobs?category=sales&location=texas`. These URLs are "internal search result pages." Unlike your product or category pages, search result pages contain no unique content of their own — they just reflect whatever a user happened to type. Because the query string can be almost anything, your site can generate millions of slightly different URLs, each showing slightly different (or empty) results. Right now, Google can find and index those URLs, meaning they appear — or could appear — in search engine results.

Indexable internal search pages damage your SEO in three concrete ways. First, they dilute your crawl budget: Googlebot wastes time fetching thousands of low-value search URLs instead of your actual product and category pages — pages that actually drive revenue. Second, search result pages are "thin content" in Google's eyes (little original text, no unique value), which can drag down your site's overall quality signal and reduce rankings for your real pages. Third, an unbounded query-string space creates a theoretically infinite number of URLs, which can cause Google to deprioritize your entire domain as a crawl and index target. Blocking these pages costs you nothing in organic traffic (nobody reaches your site by Googling your own search results) and frees up crawl budget and authority for the pages that actually sell.

See the complete Search results indexable guide for every platform and the full background.

Not sure if your Next.js (Headless) store has this?

Run a free SEOLZ scan — we’ll find search results indexable and every other issue across your whole site.

Scan my site free

Fix search results indexable on another platform