Reference guide · technical-seo · Published 2026-08-16 · 4 min read

Using the x-robots-tag HTTP header

x-robots-tag header: directives, per-response control, non-HTML support, and how it compares with meta robots and robots.txt.

What the x-robots-tag header is

X-Robots-Tag is an HTTP response header that carries the same indexing directives as the robots meta element, but set on the server side. Instead of living inside a page's HTML, it arrives with every response:

HTTP/1.1 200 OK
Content-Type: application/pdf
X-Robots-Tag: noindex, nofollow

That one line tells search engines not to index the returned resource and not to follow its links. Because it is an HTTP header, it can be applied to any resource, including files that have no HTML head to carry a meta tag: PDFs, images, videos, API responses and feeds.

Directives

X-Robots-Tag accepts the same values as the meta robots element, plus a few Google-specific ones:

DirectiveMeaning
noindexDo not index this resource
nofollowDo not follow links from it
noarchiveDo not save a cached or archived copy
nosnippetShow no text or video snippet in results
max-snippet:150Allow a snippet up to 150 characters (Google)
max-image-preview:standardBound the largest image preview size shown
unavailable_after:2026-09-01Stop showing this result after a date (Google)

You can combine values in one header: X-Robots-Tag: noindex, nofollow. More than one value with different scopes (like none and max-snippet) can also be declared by sending the header multiple times, one value each.

x-robots-tag vs meta robots vs robots.txt

The three indexing controls overlap and interact:

Google's rule when the header and the meta tag disagree: it acts on the most restrictive value. A page with meta robots: noindex in the body and a X-Robots-Tag: noindex header carries the restriction twice, which is harmless; it is the situations where one says can and the other says cannot that the restrictive one wins.

Why you would use the header

  1. Non-HTML files: PDFs, DOCX, images, audio. A PDF has no head, so the header is the only per-resource directive.
  2. Response-level logic: the web server or CDN can set the header for every file of a type in one rule, without touching HTML. For example, add X-Robots-Tag: noindex on every /downloads/*.pdf path at the edge.
  3. Per-page control with payloads that do not care: CDNs, Workers, edge functions and .htaccess/nginx configs can all emit it. The header works even when the page itself is cached.

The shared pattern with WordPress or static hosting: set the noindex on content you want discoverable but not directly in the results (thank-you pages, filters, temporary paths) while the URL stays crawlable.

Setting it: three examples

Apache (.htaccess)

<Files "*.pdf">
  Header set X-Robots-Tag "noindex"
</Files>

nginx

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

Cloudflare / edge: a redirect or transform rule adds X-Robots-Tag: noindex on the passthrough.

Run them per environment. The rule does not send robots.txt content; it sends only the header, so the resource stays crawlable but deindexed.

Verify

Check the response directly:

The URL inspection flow and the canonical tag guide complete the deindexing story, because the header alone does not fight canonical choices.

Need a website built, fixed, optimised, migrated or replaced?

This technical resource is written by CSMBAC, a small design and development studio. If you would rather hand the problem to a professional, the website service page explains how we build enquiry-ready websites.

Explore website services