Skip to content
MrKeyword
Technical SEO

X-Robots-Tag: what it is, how it differs from meta robots, and how to noindex PDFs

The X-Robots-Tag HTTP response header tells search engines how to treat a URL: index or not, follow links or not, show snippets or not. It uses the same directives as the HTML robots meta tag, but it works on files that have no HTML head, such as PDFs, images and plain text. This guide lists every common directive, shows copy-paste server config for noindex on PDFs and whole folders, explains the robots.txt trap, and points you to free tools that read the header on any URL.

A checklist-style dashboard of page and header checks
The short version
  • X-Robots-Tag is the HTTP header form of Google's robots directives. It applies to the whole response, including PDFs, images and other non-HTML URLs.
  • It supports the same rules as <meta name="robots">: noindex, nofollow, none, snippet controls and more.
  • To noindex every PDF, set the header on .pdf responses in Apache, Nginx, Next.js or Cloudflare; meta tags inside a PDF are not how Google reads robots rules.
  • If robots.txt blocks a URL, Googlebot never downloads it, so it never sees an X-Robots-Tag on that URL. Use noindex on a crawlable URL, or remove the disallow.
  • Confirm the live header with MrKeyword's free HTTP header checker or the indexability checker.

What is X-Robots-Tag?

X-Robots-Tag is an HTTP response header that carries the same indexing and snippet rules as the HTML <meta name="robots"> tag. Google's block indexing documentation lists two ways to keep a URL out of search results: a noindex robots meta tag in the page, or an X-Robots-Tag HTTP header on the response. Crawlers that support Google's rules read whichever signal they receive when they fetch the URL.

Because the header is attached to the HTTP response, not to HTML, it is the practical way to control indexing for resources that are not web pages: PDFs, Word documents, images, video files and plain text. A PDF cannot carry a <meta name="robots"> tag in a way search engines use for indexing; the header on the download URL is what matters.

X-Robots-Tag vs the robots meta tag

Both channels accept the same directive names and values; only the delivery mechanism differs. Use a meta tag when you control the HTML <head>. Use X-Robots-Tag when you do not, or when one server rule should cover many files (every PDF, everything under /private/, or all responses from an API route).

  • HTML pages: either a meta tag or the header works. If both are present on the same URL, Google treats them as a combined set of rules; avoid sending conflicting directives.
  • Non-HTML files: rely on X-Robots-Tag (or on not linking the file publicly). There is no standard in-page robots meta for a binary PDF body.
  • Visibility: the meta tag appears in View Source; the header does not. That is why accidental noindex on PDFs is easy to miss until you inspect response headers.

For a page-level checklist that includes both signals, see our on-page SEO checklist.

Directives Google supports

Google documents these in its robots meta tag reference. You can list several in one header, separated by commas.

Common X-Robots-Tag values

DirectiveEffect
noindexDo not show this URL in Google Search results.
nofollowDo not follow links on this resource for ranking purposes.
noneEquivalent to noindex, nofollow, nosnippet, noarchive.
noarchiveDo not show a cached link in search results.
nosnippetDo not show a text snippet in search results (still may be indexed unless combined with noindex).
max-snippet:[number]Limit snippet length to the given number of characters.
max-image-preview:none or standard or largeControl the largest image preview allowed in search results.
unavailable_after: [date/time]Ask Google to drop the page from the index after the given date, in RFC 822 format.
Summarised from Google Search Central. Other search engines may support a smaller set.

Rules for one crawler only

You can prefix a directive with a user-agent token so it applies only to that crawler. Google's documentation gives the form X-Robots-Tag: googlebot: noindex to noindex a URL for Googlebot while leaving other crawlers unchanged. The same pattern works for other supported tokens documented on Google's robots meta tag page.

Use this when you need different behaviour for Googlebot and Bingbot on the same file, not as a substitute for authentication on private content.

Copy-paste examples: noindex PDFs and folders

Pick the layer that serves the file. These examples set noindex, nofollow on purpose; drop nofollow if you still want link equity from URLs inside the file.

Apache (.htaccess): every PDF


  Header set X-Robots-Tag "noindex, nofollow"
Requires mod_headers. Matches any URL whose path ends in .pdf.

Apache: a whole folder


  Header set X-Robots-Tag "noindex, nofollow"
Applies to every URL under /private/ on this host. Adjust the path to match yours.

Nginx: every PDF

location ~* \.pdf$ {
  add_header X-Robots-Tag "noindex, nofollow" always;
}
The always flag adds the header on error responses too, which matters for some PDF URLs.

Nginx: a whole folder

location ^~ /private/ {
  add_header X-Robots-Tag "noindex, nofollow" always;
}
Prefix match for everything under /private/.

Next.js (App Router): PDF paths

export async function headers() {
  return [
    {
      source: "/files/:path*.pdf",
      headers: [{ key: "X-Robots-Tag", value: "noindex, nofollow" }],
    },
  ];
}
Place in next.config.js or export headers from a route segment config, depending on your Next.js version.

Cloudflare Transform Rules (response header)

Set static header
Name: X-Robots-Tag
Value: noindex, nofollow

When: URI Path matches regex \.pdf$
In the dashboard: Rules → Transform Rules → Modify Response Header. Scope the rule to PDFs or to a path prefix the same way you would in Nginx.

After you deploy, fetch one live PDF URL in the HTTP header checker. A misconfigured CDN can strip or override headers set at the origin.

The robots.txt trap

If robots.txt disallows a URL, Googlebot will not fetch it, so it never sees an X-Robots-Tag on that response. Google's noindex documentation is explicit: it does not support noindex in robots.txt, and when robots.txt blocks crawling, the crawler cannot read a noindex directive on the page or in headers either.

That breaks a common mistake: disallow /pdf/ in robots.txt and also set X-Robots-Tag: noindex on those PDFs. The disallow wins for crawling; the header never runs. To remove URLs from the index while keeping them crawlable, allow Googlebot to fetch them and send noindex (meta or header). To keep URLs private, use login walls rather than relying on robots.txt alone.

Test whether a URL is allowed for a given bot with the free robots.txt tester before you depend on header-based noindex.

How to check X-Robots-Tag on a live URL

  1. Read every response header

    Paste the URL into MrKeyword's free HTTP header checker. It lists status, redirects and headers, and highlights x-robots-tag when present. That is the fastest way to answer searches for x-robots-tag noindex on a specific file.

  2. See indexability in one report

    The free indexability checker combines HTTP status, robots.txt, canonical, meta robots and X-Robots-Tag so you can see whether anything blocks indexing.

  3. Confirm in Search Console

    For HTML URLs you control, URL Inspection shows the HTML Google fetched. For PDFs, check the live header first, then use the coverage reports after Google recrawls.

See X-Robots-Tag on any URLPaste an address and get every response header in seconds, with no account.

Open the header checker

Questions and answers

X-Robots-Tag explained questions

What is X-Robots-Tag?

It is an HTTP response header that tells search engines how to treat a URL, using the same directives as the HTML robots meta tag. Google reads it when it fetches the URL.

How do I noindex a PDF?

Send X-Robots-Tag: noindex on the HTTP response when the PDF is served, for example with Apache FilesMatch, an Nginx location for .pdf, a Next.js headers() rule, or a Cloudflare Transform Rule. Meta tags inside the PDF file are not the control Google documents for this job.

What is the difference between X-Robots-Tag and meta name robots?

They accept the same directive names. The meta tag lives in HTML; the header works on any response, including PDFs, images and other non-HTML files that have no head element.

Can I use X-Robots-Tag and robots.txt noindex together?

Google does not support noindex in robots.txt. If robots.txt disallows a URL, Googlebot will not fetch it and will not see X-Robots-Tag on that URL. Use a crawlable URL plus noindex in the header or HTML, or block access another way.

How do I noindex for Googlebot only?

Google documents per-crawler values such as X-Robots-Tag: googlebot: noindex on the same response. Other crawlers may still index the URL unless you send matching rules for them too.

About this article

Written by the MrKeyword team, who build an SEO workspace on first-party Search Console and Bing data. Outside facts link to their original source below. We update this page when the product or the sources change.

Sources

  1. Block search indexing with noindex — Google Search Central, on meta robots, X-Robots-Tag and robots.txt
  2. Robots meta tag, data-nosnippet, and X-Robots-Tag specifications — Google Search Central, directive list and per-user-agent syntax
  3. Control your snippets in search results — Google Search Central, on nosnippet, max-snippet and max-image-preview
Keep reading

More on technical SEO, plus the feature and free tool for the same job. All technical SEO guides →

Confirm the header on every PDF you care about.

Paste any URL into the free HTTP header checker and read X-Robots-Tag before you assume a folder rule worked. Free plan for one website, no card; paid plans from $10 a month.