Nightcrop
LoginGet started

X-Robots-Tag: What It Is and How to Set It Up

Nightcrop · November 19, 2026

X-Robots-Tag is an HTTP response header that gives search engines the same instructions as a robots meta tag, such as noindex or nosnippet. Use it for files with no HTML head, like PDFs and images, or to apply a rule across a whole folder from your server settings.

What is the X-Robots-Tag header?

When a browser or crawler requests a URL, the server replies with headers before the content. One of them can be X-Robots-Tag. Google's robots meta tag documentation describes it as a way to send the same indexing and serving rules as the meta tag, with the advantage that it works for any file type and can be set from server configuration.

A typical response carries one line: X-Robots-Tag: noindex. That tells search engines to keep this file out of their results. If you want the full idea behind that rule, read about the noindex tag.

When should you use it instead of a meta tag?

A meta tag lives in the <head> of an HTML page. That is fine for normal pages, and it is simpler to manage in a CMS. The header is the better tool in three situations:

For everyday pages, a meta tag is easier to audit because you can see it when you view the page source.

How do you set X-Robots-Tag on Apache and nginx?

Google's documentation gives these patterns. Both block indexing of PDF files.

Apache

In .htaccess or the server config, with the mod_headers module enabled:

<FilesMatch "\.pdf$">
Header set X-Robots-Tag "noindex, nofollow"
</FilesMatch>

nginx

Inside a server or location block:

location ~* \.pdf$ {
add_header X-Robots-Tag "noindex, nofollow";
}

After changing the config, reload the server and test one file. Do not assume the rule works until you have seen the header in a real response.

How do you check that the header is being sent?

Run curl -I https://example.com/file.pdf in a terminal. The -I flag asks for headers only. Look for an x-robots-tag line in the output. You can also open your browser's developer tools, go to the Network tab, click the file, and read the response headers. In Search Console, the URL Inspection tool reports whether indexing is blocked by a noindex rule.

Check more than one file type. A rule that matches .pdf will not touch .docx, and a CDN in front of your server can strip or override headers.

Which values can X-Robots-Tag carry?

These are the values Google documents:

ValueWhat it does
noindexKeeps the resource out of search results
nofollowAsks Google not to follow links on the resource
nosnippetHides the text snippet and video preview; a static image thumbnail may still appear
max-snippet:[number]Limits the text snippet to that many characters; 0 acts like nosnippet, -1 lets Google decide
unavailable_after:[date]Stops showing the page after a date given in a standard format such as ISO 8601

You can combine rules in one header with commas, or send several headers. A rule can also be limited to one crawler by adding its name first, for example googlebot: nofollow. Rules without a name apply to every crawler. If two rules conflict, the stricter one wins.

Why does robots.txt stop X-Robots-Tag from working?

A crawler only sees a header when it fetches the URL. If your robots.txt disallows that URL, the crawler never makes the request, so the header is never read. Google states this directly in the documentation linked above. The result is a file you meant to hide that can still show up in results if other pages link to it.

The fix is to leave the URL crawlable and let the header do its job. Our comparison of robots.txt vs noindex goes through when to use each one.

Does X-Robots-Tag control AI crawlers?

Only to the extent each crawler chooses to honor it. The Google documentation is about Google's own rules, and it notes that other search engines may not read these rules the same way. If your goal is to control AI crawlers, the dependable tool is robots.txt with named user agents. Start with how to block AI crawlers and check each bot's own documentation for what it supports.

Common mistakes

Frequently Asked Questions

Is X-Robots-Tag the same as the robots meta tag?

The rules are the same. The difference is delivery: one is an HTTP header and the other sits in the page's HTML head.

Can I use X-Robots-Tag on images and PDFs?

Yes. That is its main use, because those files cannot contain a meta tag.

Does X-Robots-Tag work if the page is blocked in robots.txt?

No. The crawler never fetches the URL, so it never sees the header. Remove the block if you need the rule to apply.

How do I see an X-Robots-Tag on a page?

Use curl -I on the URL, or open the Network tab in your browser's developer tools and read the response headers.

Can I target only Googlebot?

Yes. Put the crawler name before the rule, as in googlebot: noindex. Rules without a name apply to all crawlers.