Free auditStart free
GuideNext.js · Indexing

Next.js noindex

Noindex Next.js pages with the metadata robots option or an X-Robots-Tag header in next.config.js, avoid robots.txt conflicts, and verify the live output.

3 min
read
5
sources
Nov 1, 2026
updated
Scaplet Editorial Team
author
In one line

In the Next.js App Router, export metadata with a robots object from a layout or page to set the robots meta tag; use index: false for noindex and confirm the rendered tag on your build. For PDFs and other non-HTML files, return an X-Robots-Tag: noindex header from headers() in next.config.js. Don't block the URL in robots.txt: Google has to crawl the page to see the rule.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode

At a glance

4 facts from the sources below
metadata.robots
HTML pages
X-Robots-Tag header
Any file type
robots object is replaced, not merged
Merge behavior
robots.txt Disallow
Do not combine with
01Meta tag or header

Pick the method by what you are serving

Situation

A page rendered by a layout or page file

Use
metadata.robots or generateMetadata
Why
Sets a robots meta tag in the page head.
Situation

A PDF, image, or other non-HTML file

Use
X-Robots-Tag in headers()
Why
Google says a response header can be used for non-HTML resources.
Situation

A whole path prefix at once

Use
X-Robots-Tag in headers() with a source pattern
Why
One rule covers every route that matches the pattern.
Situation

A not-found page

Use
Nothing
Why
Next.js injects <meta name="robots" content="noindex" /> for pages that return a 404 status code.

Google says the meta tag and the header have the same effect, so choose the one that fits the content type. Both are read only when Googlebot crawls the page: when it extracts the rule, Google drops the page entirely from Search results, regardless of whether other sites link to it.

02Check it

Noindex with the metadata API

Next.js documents the robots field with index: true and follow: true outputting <meta name="robots" content="index, follow" />. The docs page doesn't show the output for index: false, so confirm on your own build, with the check below, that the example renders a noindex value. For a condition that depends on data, return the same object from generateMetadata.

app/internal/page.tsx
import type { Metadata } from 'next'

export const metadata: Metadata = {
  robots: {
    index: false,
    follow: false,
  },
}

export default function Page() {
  return <h1>Internal page</h1>
}
03Worth knowing

Noindex with an X-Robots-Tag header

Pattern syntax

source is the incoming request path pattern. /internal/:path* matches /internal and every nested path, because * means zero or more.

Files too

Headers are checked before the filesystem, which includes pages and /public files.

Overlapping rules

If two header rules match the same path and set the same key, the last one overrides the first. Keep one X-Robots-Tag rule per path to avoid surprises.

Crawler targeting

Google lets an X-Robots-Tag start with a user agent, for example googlebot: nofollow, and allows none as a value equivalent to noindex, nofollow.

next.config.js
module.exports = {
  headers() {
    return [
      {
        source: '/internal/:path*',
        headers: [
          {
            key: 'X-Robots-Tag',
            value: 'noindex',
          },
        ],
      },
    ]
  },
}
04Checklist

Do not block what you noindex

For noindex to work, the page must not be blocked by robots.txt and has to be otherwise accessible. Google says that if the crawler can't fetch the page it never sees the rule, and the page can still appear in results, for example when other pages link to it. Google also doesn't support a noindex rule inside robots.txt. Review your Next.js robots.txt before shipping.
  1. 01Sitemap. Don't list a noindexed URL in your XML sitemap, since listing it invites a crawl you don't want indexed.
  2. 02Canonicals. Don't point a canonical at a noindexed page. See canonical tags in Next.js.
  3. 03Timing. Google says that if a page still appears, it probably hasn't been crawled since you added the rule, and that depending on the importance of the page, a revisit may take months. Request a recrawl with URL Inspection.
  4. 04Accidents. A robots setting in a root layout applies to every route that doesn't override it. Read the noindex glossary entry and audit your layouts.
05How it works

Check it worked

Read the live response
# Meta tag in the HTML
curl -s https://example.com/internal | grep -i 'name="robots"'

# Header on the response
curl -sI https://example.com/internal | grep -i x-robots-tag
  1. 01

    Test the production hostname

    Run the commands against the deployed site, not localhost, so any CDN or proxy rule is included.

  2. 02

    Use URL Inspection

    To see the HTML Googlebot received while crawling the page, use the URL Inspection tool in Search Console.

  3. 03

    Monitor the report

    Google says the Page Indexing report in Search Console shows pages from which Googlebot extracted a noindex rule.

Questions

Asked a lot.

3 questions people ask next, answered from the sources on this page.

01How do I noindex a page in Next.js?

Export metadata with robots: { index: false } from the page or layout, or send an X-Robots-Tag: noindex header using headers() in next.config.js. Don't disallow the URL in robots.txt.

02Does Next.js add noindex to 404 pages automatically?

Yes. Next.js injects <meta name="robots" content="noindex" /> for pages that return a 404 status code, including global-not-found.js pages.

03Can I noindex a PDF in Next.js?

Use the header method. Google says an X-Robots-Tag response header can be used for non-HTML resources such as PDFs, video files, and image files.

Sources · 5

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • nextjs.org
  • google.com
  1. 01generateMetadata: robots and merging | Next.js Documentationnextjs.org · checked 2026-11-01
  2. 02headers | Next.js Documentationnextjs.org · checked 2026-11-01
  3. 03not-found.js | Next.js Documentationnextjs.org · checked 2026-11-01
  4. 04Block Search indexing with noindex | Google Search Centraldevelopers.google.com · checked 2026-11-01
  5. 05Robots meta tag, data-nosnippet, and X-Robots-Tag specifications | Google Search Centraldevelopers.google.com · checked 2026-11-01
Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane