# 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.

Canonical: https://scaplet.com/seo/nextjs/noindex

Guide Next.js Next.js · Indexing

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 with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%2Fnoindex%20(%22Next.js%20noindex%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%2Fnoindex%20(%22Next.js%20noindex%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%2Fnoindex%20(%22Next.js%20noindex%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%2Fnoindex%20(%22Next.js%20noindex%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

## 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

_01_Meta 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](/glossary/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](/glossary/http-status-codes).

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](/ai-crawlers/googlebot) crawls the page: when it extracts the rule, Google drops the page entirely from [Search results](/glossary/serp), regardless of whether other sites link to it.

_02_Check 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`.

**Child robots objects replace parent ones**Metadata from multiple segments is shallowly merged, and nested fields such as `robots` defined in an earlier segment are overwritten by the last segment to define them. If your root layout sets `googleBot` options and a page sets only `index: false`, the page's object wins entirely. Repeat any fields you still need.

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> }
```

_03_Worth 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](/glossary/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', }, ], }, ] }, }
```

_04_Checklist

## Do not block what you noindex

For [noindex](/glossary/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](/seo/nextjs/robots-txt) before shipping.

1. 01 **Sitemap.** Don't list a noindexed URL in your [XML sitemap](/seo/nextjs/xml-sitemap), since listing it invites a crawl you don't want indexed.
2. 02 **Canonicals.** Don't point a canonical at a noindexed page. See [canonical tags in Next.js](/seo/nextjs/canonical-tags).
3. 03 **Timing.** 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. 04 **Accidents.** A `robots` setting in a root layout applies to every route that doesn't override it. Read the [noindex glossary entry](/glossary/noindex) and audit your layouts.

_05_How 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.

_01_ How 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.

_02_ Does 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.

_03_ Can 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. 01 [generateMetadata: robots and merging | Next.js Documentation](https://nextjs.org/docs/app/api-reference/functions/generate-metadata) nextjs.org · checked 2026-11-01
2. 02 [headers | Next.js Documentation](https://nextjs.org/docs/app/api-reference/config/next-config-js/headers) nextjs.org · checked 2026-11-01
3. 03 [not-found.js | Next.js Documentation](https://nextjs.org/docs/app/api-reference/file-conventions/not-found) nextjs.org · checked 2026-11-01
4. 04 [Block Search indexing with noindex | Google Search Central](https://developers.google.com/search/docs/crawling-indexing/block-indexing) developers.google.com · checked 2026-11-01
5. 05 [Robots meta tag, data-nosnippet, and X-Robots-Tag specifications | Google Search Central](https://developers.google.com/search/docs/crawling-indexing/robots-meta-tag) developers.google.com · checked 2026-11-01

## Keep learning

[All platform guides](/seo)

[Learn Next.js canonical tags Frameworks](/seo/nextjs/canonical-tags) [Related Robots meta tag Crawling and indexing](/glossary/robots-meta-tag) [Read next Next.js robots.txt Frameworks](/seo/nextjs/robots-txt) [Do Run a free site audit Free, about two minutes](/site-audit)

More in Next.js SEO
[Next.js 404 page](/seo/nextjs/404) [Next.js AI crawlers](/seo/nextjs/ai-crawlers) [Next.js canonical tags](/seo/nextjs/canonical-tags) [Next.js Google Analytics](/seo/nextjs/google-analytics) [Next.js image SEO](/seo/nextjs/image-seo) [Next.js lazy loading](/seo/nextjs/lazy-loading) [Next.js noindex](/seo/nextjs/noindex) [Next.js redirects](/seo/nextjs/redirects) [Next.js robots.txt](/seo/nextjs/robots-txt) [Next.js structured data](/seo/nextjs/structured-data) [Next.js title and meta description](/seo/nextjs/title-and-meta) [Next.js XML sitemap](/seo/nextjs/xml-sitemap)

Terms on this page
[Robots meta tag](/glossary/robots-meta-tag) [HTTP status codes](/glossary/http-status-codes) [SERP](/glossary/serp) [User agent](/glossary/user-agent) [Noindex](/glossary/noindex)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

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

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
