X-Robots-Tag Header Guide with Syntax, Setup and Checks

Contents+
- 01What is the X-Robots-Tag header?
- 02X-Robots-Tag syntax and examples
- 03Which directives does X-Robots-Tag support?
- 04When should you use X-Robots-Tag over a meta robots tag?
- 05How to set X-Robots-Tag on your server or platform
- Apache
- NGINX
- Next.js
- Vercel
- Cloudflare
- 06How to check the X-Robots-Tag on a URL
- 07How X-Robots-Tag interacts with robots.txt
- 08Common X-Robots-Tag mistakes
The X-Robots-Tag is an HTTP response header that tells search engines how to index and show a URL. It accepts the same rules as the robots meta tag, such as noindex and nosnippet. Because it travels in the response headers, it works on PDFs, images and any other file that has no HTML head to hold a meta tag.
This guide covers the syntax and the supported directives. It also shows how to set the header on Apache, NGINX, Next.js, Vercel and Cloudflare, how to check it, and why robots.txt can hide it from Google entirely.
What is the X-Robots-Tag header?
Google's robots meta tag, data-nosnippet and X-Robots-Tag specification defines two ways to give page-level indexing rules. One is a meta tag in the HTML. The other is the X-Robots-Tag header in the HTTP response. Any rule that works in the meta tag also works in the header.
A response carrying the header looks like this.
HTTP/1.1 200 OK
Date: Tue, 25 May 2010 21:42:43 GMT
X-Robots-Tag: noindex
Crawlers read the header when they fetch the URL. Visitors never see it. Neither does anyone reading the page source. That makes it powerful for files and easy to miss in an audit.
X-Robots-Tag syntax and examples
The header takes one or more rules separated by commas. Google's specification also lets you send several X-Robots-Tag headers in one response.
X-Robots-Tag: noindex, nofollow
Separate headers work too.
X-Robots-Tag: noimageindex
X-Robots-Tag: unavailable_after: 25 Jun 2010 15:00:00 PST
To aim a rule at one crawler, put its user agent name before the rules. Rules without a name apply to every crawler that supports them.
X-Robots-Tag: googlebot: nofollow
X-Robots-Tag: otherbot: noindex, nofollow
Google's specification says the header name, the rule values and the user agent names are case-insensitive. When rules conflict, "the more restrictive rule applies." A noindex in the header beats an index in the page's meta tag.
Which directives does X-Robots-Tag support?
Google lists these rules for both the meta tag and the header, as of December 2026.
| Rule | What it does |
|---|---|
all | No restrictions. It's the default and has no effect when listed. |
noindex | Keeps the page, media or resource out of search results |
nofollow | Tells Google not to follow the links on the page |
none | Equivalent to noindex, nofollow |
nosnippet | Blocks text snippets and video previews in results |
indexifembedded | Lets Google index the content when it's embedded in another page through an iframe. It works only alongside noindex. |
max-snippet:[number] | Caps the text snippet length in characters. 0 means no snippet and -1 lets Google choose. |
max-image-preview:[setting] | Sets the largest image preview to none, standard or large |
max-video-preview:[number] | Caps video previews in seconds |
notranslate | Stops Google from offering a translation of the page in results |
noimageindex | Keeps images on the page out of the index |
unavailable_after:[date/time] | Drops the page from results after the given date and time |
Google says it ignores noarchive, nocache and nositelinkssearchbox. Other search engines publish their own lists.
When should you use X-Robots-Tag over a meta robots tag?
Use the meta tag for ordinary HTML pages your CMS or framework already controls. Reach for the header in the cases below.
| Situation | Why the header fits |
|---|---|
| PDFs, Word files and spreadsheets | There's no HTML head to hold a meta tag. Google's specification recommends the header for non-HTML resources. |
| Image and video files | A noindex on the file itself keeps that file out of search results. |
| A whole host or directory | One server or CDN rule covers every response. Staging hosts and link shorteners are typical examples. |
| Generated assets you can't edit | Framework routes such as social card images return files with no template to change. |
| HTML you can't touch | Third-party or legacy pages where only the server or CDN is under your control |
For the meta tag side and the Search Console status it produces, see our noindex tag guide.
How to set X-Robots-Tag on your server or platform
Apache
Response headers come from the Header directive in mod_headers. Google's specification gives this example for PDFs.
<Files ~ "\.pdf$">
Header set X-Robots-Tag "noindex, nofollow"
</Files>
Images follow the same pattern.
<Files ~ "\.(png|jpe?g|gif)$">
Header set X-Robots-Tag "noindex"
</Files>
NGINX
Google's NGINX equivalents use add_header inside a location block.
location ~* \.pdf$ {
add_header X-Robots-Tag "noindex, nofollow";
}
Here's the image version.
location ~* \.(png|jpe?g|gif)$ {
add_header X-Robots-Tag "noindex";
}
Two NGINX behaviors catch people out. The headers module documentation says add_header directives are inherited from the previous level "if and only if there are no add_header directives defined on the current level." A location that adds any header of its own drops the X-Robots-Tag set at the server level. The header also applies only to a fixed list of success and redirect codes unless you add the always parameter.
Next.js
The metadata object's robots field in the App Router writes a meta tag into the page head. For files and whole hosts, use headers() in next.config.ts, as described in the Next.js headers documentation.
This site runs on Next.js. Here are two rules from our own config, lightly trimmed. The first keeps generated social card images out of search results. The second applies noindex to every response on our link shortener host, go.search.agency.
async headers() {
return [
{
source: "/:p(.*opengraph-image.*)",
headers: [{ key: "X-Robots-Tag", value: "noindex" }],
},
{
source: "/:path*",
has: [{ type: "header", key: "x-forwarded-host", value: "go.search.agency" }],
headers: [{ key: "X-Robots-Tag", value: "noindex" }],
},
];
}
Our broader setup, including metadata and sitemaps, is in our Next.js SEO guide.
Vercel
Projects on Vercel can set headers in vercel.json with the same source and headers shape, per the vercel.json reference. This example covers every file in a downloads folder.
{
"headers": [
{
"source": "/downloads/(.*)",
"headers": [{ "key": "X-Robots-Tag", "value": "noindex" }]
}
]
}
Vercel also adds X-Robots-Tag: noindex to preview deployments by itself. Its guide on preview indexing notes an exception. Vercel doesn't add the header when a preview is served from a custom domain assigned to a Git branch. A host like staging.example.com needs protection or a header you set yourself.
Cloudflare
On Cloudflare, a response header transform rule can add the header at the edge for any hostname or path you match. Use a Set static operation with the header name X-Robots-Tag and your rules as the value. Cloudflare's documentation says Set operations replace all existing headers of that name. An Add operation keeps them.
Edge rules are fast to ship and easy to forget. Our post on edge SEO at the CDN covers how to keep them documented.
How to check the X-Robots-Tag on a URL
The quickest check is curl from your terminal. Here is our link shortener host on December 4, 2026.
$ curl -sI https://go.search.agency/ | grep -iE '^(HTTP|x-robots-tag)'
HTTP/2 200
x-robots-tag: noindex
And here is a generated social card image from our main site, served as a PNG with the header attached.
$ curl -sI https://search.agency/opengraph-image | grep -iE '^(HTTP|content-type|x-robots-tag)'
HTTP/2 200
content-type: image/png
x-robots-tag: noindex
The -I flag sends a HEAD request. Some servers answer HEAD and GET differently. To see the headers of a real GET request, run curl -s -o /dev/null -D - https://example.com/file.pdf instead.
Two other tools show it.
- URL Inspection in Search Console. The URL Inspection documentation says View crawled page shows the raw HTML and the HTTP headers Google received. That's the version Google acted on.
- Browser developer tools. Open the Network panel, reload and click the document or file to read its response headers.
Headers added by a CDN only appear on requests that pass through it. Test the public URL. A request to the origin server can miss the rule entirely.
How X-Robots-Tag interacts with robots.txt
Google has to fetch a URL to read its headers. The specification says that if robots.txt disallows crawling a URL, any indexing or serving rules on it "will not be found and will therefore be ignored."
That makes robots.txt and X-Robots-Tag: noindex a bad pair. A disallowed PDF with a noindex header can still be indexed from links pointing at it. Google never sees the header. Allow crawling, let Google recrawl the file and read the noindex, and only then decide whether a disallow rule is worth adding back. Our guide to Blocked by robots.txt walks through that order.
Common X-Robots-Tag mistakes
| Mistake | What happens | Fix |
|---|---|---|
| Staging header copied to production | A noindex meant for staging ships with the server or CDN config and removes live pages from results. | Scope the rule by hostname. Check production headers after every config release. |
| NGINX inheritance | A location block with its own add_header silently drops the server-level X-Robots-Tag. | Repeat the header in that block. On NGINX 1.29.3 or later, add_header_inherit merge; keeps the parent headers. |
| Disallowed in robots.txt | Google never fetches the URL and never reads the header. | Allow crawling until the URL leaves the index. |
| Rule too broad | A pattern written for PDFs also matches HTML pages, such as a regex without an end anchor. | Anchor file patterns and test a page URL alongside the files. |
| Conflicting header and meta tag | The more restrictive rule wins. An old header noindexes a page whose meta tag says index. | Search both places when a page drops out. |
| Branch preview on a custom domain | Vercel's automatic preview header doesn't apply. | Add the header yourself or protect the deployment. |
A header-driven noindex shows up in Search Console under the same reason as the meta tag version. Our Page indexing report guide explains where to find it. When a release starts dropping pages and nobody can find the cause in the HTML, our technical SEO team can trace the headers across your server, CDN and framework.
See where your brand stands in AI answers today, benchmarked against your competitors, no pitch required.
Related reading
All posts →
Noindex Tag Guide with Syntax, Robots.txt Pitfalls and Fixes
The noindex tag keeps a page out of Google once Google can crawl it and read the rule. This guide covers syntax, the robots.txt trap and the accidents that noindex pages you want ranking.
Read post →
How one HTTP header can feed Googlebot a stale, fragmented copy of your page
The HTTP Vary header tells caches which request headers shaped a response. Here is its syntax, the common values, how browsers and CDNs apply it, and how a careless value feeds Googlebot stale, fragmented HTML.
Read post →
How to Set Bing AI Training and AI Grounding Controls
Bing now separates AI training from AI grounding. Training is set in robots.txt, grounding only page by page. Setup for meta tags, Cloudflare, Nginx and Apache.
Read post →