Most people control indexing with a robots meta tag in the page's HTML. That works for web pages, but what about a PDF price list, a folder of images or thousands of URLs you want to handle with one server rule? You cannot put a meta tag inside a PDF.
That is what the X-Robots-Tag is for. It carries the same indexing and snippet rules as the robots meta tag, but in the HTTP response header instead of the HTML. It is powerful, flexible and, because it lives in server configuration, easy to forget about until something important disappears from search.
This guide explains how the X-Robots-Tag works, which rules it supports, how to set it on Apache and nginx, how to check it, and the mistakes that cause accidental de-indexing.
Key Takeaways
- The X-Robots-Tag is an HTTP response header that applies robots rules such as
noindexto any URL, including non-HTML files. - It supports the same rules as the robots meta tag, and rules can target specific crawlers by name.
- Crawlers must be allowed to fetch the URL to see the header; blocking it in robots.txt hides the rule.
- When rules conflict, Google applies the more restrictive one.
- Because it is invisible in the page source, check headers regularly during audits and after server changes.
What Is the X-Robots-Tag?
Google's documentation describes it simply:
“The X-Robots-Tag can be used as an element of the HTTP header response for a given URL.”
— Google Search Central, Robots meta tag, data-nosnippet, and X-Robots-Tag specifications
Any rule you can use in a robots meta tag can also be sent as an X-Robots-Tag. MDN notes that the header is not part of a formal specification but is a de facto standard that cooperative crawlers follow. A minimal response looks like this:
HTTP/1.1 200 OK
Content-Type: application/pdf
X-Robots-Tag: noindex
Google states that the values are not case sensitive. You can send several rules in one header separated by commas, or send multiple X-Robots-Tag headers.
X-Robots-Tag vs Robots Meta Tag vs robots.txt
| Method | Where it lives | Controls | Works for non-HTML files? | Best for |
|---|---|---|---|---|
| robots.txt | A file at the site root | Crawling | Yes (blocks fetching) | Saving crawl resources on unimportant URLs |
| Robots meta tag | HTML <head> | Indexing and snippets | No | Individual HTML pages, set in a CMS |
| X-Robots-Tag | HTTP response header | Indexing and snippets | Yes | PDFs, images, video, and site-wide rules by pattern |
The key distinction is crawling versus indexing. robots.txt can stop a crawler fetching a URL, but it does not reliably keep that URL out of the index. Our article on robots.txt vs meta robots and our guide to the noindex tag go deeper.
Supported Rules
Google supports the following rules in both the meta tag and the X-Robots-Tag:
| Rule | Effect in Google Search |
|---|---|
noindex | Do not show the URL in search results |
nofollow | Do not follow links on the page |
none | Same as noindex, nofollow |
nosnippet | No text snippet or video preview; also keeps content from being used as a direct input for AI Overviews and AI Mode |
indexifembedded | Allow indexing when embedded via iframe despite noindex (used together with noindex) |
max-snippet:[n] | Limit text snippet length in characters (0 = none, -1 = no limit) |
max-image-preview:[setting] | none, standard or large image previews |
max-video-preview:[n] | Limit video preview length in seconds |
notranslate | Do not offer a translation of the result |
noimageindex | Do not index images on the page |
unavailable_after:[date] | Stop showing the URL after the given date and time |
A note on max-image-preview: Google's Discover documentation says large image previews are enabled by max-image-preview:large, so restricting it can reduce how your content appears there. See our guide to Google Discover.
Targeting Specific Crawlers and Combining Rules
You can prefix rules with a crawler name. Rules without a name apply to all crawlers:
X-Robots-Tag: noindex, nofollow
X-Robots-Tag: googlebot: noimageindex
X-Robots-Tag: unavailable_after: 2026-12-31T23:59:59+00:00
Here, all crawlers get noindex, nofollow, Googlebot additionally gets noimageindex, and the URL should stop appearing after the given date. When rules overlap or conflict, Google is explicit:
“In the case of conflicting robots rules, the more restrictive rule applies.”
— Google Search Central, Robots meta tag, data-nosnippet, and X-Robots-Tag specifications
That includes conflicts between an X-Robots-Tag header and a robots meta tag on the same page, so a forgotten header can override a CMS setting.
How to Set the X-Robots-Tag
Apache
With mod_headers enabled, add a rule to your virtual host or .htaccess:
# .htaccess or virtual host: keep all PDFs out of search results
<FilesMatch "\.pdf$">
Header set X-Robots-Tag "noindex"
</FilesMatch>
nginx
# nginx server block: keep all PDFs out of search results
location ~* \.pdf$ {
add_header X-Robots-Tag "noindex";
}
Other platforms
- CDNs and edge platforms usually let you add response headers with rules or workers; see our guide to CDNs and SEO.
- Application frameworks can set the header in code for specific routes, such as staging or internal search results.
- Managed hosts may restrict server configuration; ask support how to add custom headers.
Step-by-Step: Deploying an X-Robots-Tag Safely
- Define the goal, e.g. "remove all PDFs in /internal/ from search" or "stop indexing staging".
- List affected URLs and confirm none are pages you want to rank.
- Check robots.txt to make sure those URLs are crawlable, or Google will never see the header.
- Write the narrowest rule possible, matching specific folders or file types rather than the whole site.
- Deploy to staging first and inspect headers.
- Deploy to production and verify with a header check and the URL Inspection tool.
- Monitor the Page indexing report for "Excluded by noindex" changes.
How to Check for an X-Robots-Tag
Because the header is not in the HTML, "View source" will not show it. Use one of these methods:
- Command line: request only the headers.
curl -sI https://www.example.com/files/price-list.pdf | grep -i x-robots-tag
- Browser developer tools: open the Network tab, select the request and look at the response headers.
- Google Search Console: URL Inspection reports when indexing is blocked by a
noindexin the X-Robots-Tag. - Site crawlers: tools such as Screaming Frog report X-Robots-Tag values for every URL; see our Screaming Frog guide.
Common Mistakes
- Blocking the URL in robots.txt as well. Google's documentation explains that if crawling is disallowed, indexing rules on the URL will not be found, so they are ignored.
- Staging rules reaching production. A site-wide
noindexheader copied in a deployment can remove an entire site from search. Add a header check to your launch and migration checklists. - Overly broad patterns that match more files than intended, such as every image instead of one folder.
- Using it to save crawl budget. Crawlers still have to fetch the URL to read the header; robots.txt is the tool for that. See our crawl budget guide.
- Conflicting rules between headers, meta tags and CMS settings, where the most restrictive one silently wins.
- Restricting snippets without meaning to.
nosnippetormax-image-preview:nonecan reduce visibility in results, Discover and AI features.
Practical Use Cases
- Keeping downloadable PDFs, such as old brochures or internal documents, out of search while the HTML page describing them ranks.
- Preventing staging and development environments from being indexed (alongside authentication).
- Removing expired event or offer pages automatically with
unavailable_after. - Keeping internal search result pages out of the index across a large site.
- Applying
noimageindexto a folder of licensed images you do not want in image search.
For broader context, see our technical SEO guide, and for HTML pages specifically, the simpler meta tag approach in our noindex guide. Campaign pages are a common case too; our post on landing page SEO explains when to keep ad variants out of search, and Open Graph tags covers a different kind of head metadata. Check your HTTP status codes at the same time, because a header on an error page does not fix the underlying problem.
Related Guides
- Trailing Slashes, WWW and HTTPS: Choosing One URL Version
- Image Compression for Faster Websites
- WebP and AVIF: Next-Gen Image Formats Explained
Frequently Asked Questions
What is the X-Robots-Tag used for?
It applies robots rules such as noindex, nofollow and snippet limits through the HTTP response header. It is especially useful for non-HTML files like PDFs and images, and for applying rules by URL pattern.
Is the X-Robots-Tag better than the robots meta tag?
Neither is better; they support the same rules. Use the meta tag for individual HTML pages and the X-Robots-Tag for non-HTML files or server-level rules.
Can I use X-Robots-Tag and robots.txt together on the same URL?
Not for indexing rules. If robots.txt blocks crawling, Google cannot see the header, so the noindex is ignored. Allow crawling until the URL drops out of the index.
How do I check if a page has an X-Robots-Tag?
Inspect the response headers with browser developer tools, a command-line header request, the URL Inspection tool in Search Console or a site crawler.
Does the X-Robots-Tag affect AI Overviews?
Google says nosnippet also prevents content from being used as a direct input for AI Overviews and AI Mode, and noindex removes the URL from Search entirely.
Conclusion
The X-Robots-Tag gives you precise control over how search engines index files and URL patterns that HTML tags cannot reach. Use it narrowly, keep the affected URLs crawlable, verify headers after every deployment and watch indexing reports. Handled carefully, it is one of the most useful tools in technical SEO; handled carelessly, it is one of the quietest ways to lose traffic.
Worried about hidden indexing problems? Our SEO team includes header and indexing checks in every technical audit, and our recovery service helps when traffic has already dropped. Get a free quote.




