X-Robots-Tag (HTTP header for robots)
X-Robots-Tag is an HTTP header for controlling indexing and crawling of pages and files. It works like the robots meta tag but applies to any file type: PDFs, images, videos.
X-Robots-Tag is an HTTP response header that controls search robot behavior regarding indexing and crawling of a resource. It supports the same directives as the robots meta tag (noindex, nofollow, noarchive, etc.), but is applied at the server level.
What is X-Robots-Tag
X-Robots-Tag is an HTTP header that the server adds to a resource response. It controls search robot behavior: allowing or prohibiting indexing, link following, page caching, and other actions.
The main advantage of X-Robots-Tag over the <meta name="robots"> tag is that it works at the HTTP response level and can be applied to any resource type: HTML pages, PDF documents, images, video files, and any resource that has no HTML <head> tag.
Supported directives
- noindex
- Prevents the page from being added to the search index.
- nofollow
- Prevents the robot from following links on the page.
- noarchive
- Prevents Google from caching the page and showing a cache link.
- nosnippet
- Prevents display of a text or video snippet in search results.
- none
- Equivalent to noindex + nofollow — fully blocks indexing and link following.
- max-snippet:N
- Limits the text snippet length to N characters.
- max-image-preview:[none|standard|large]
- Controls the size of image previews in search results.
X-Robots-Tag vs. robots meta tag
| Parameter | X-Robots-Tag | Robots meta tag |
|---|---|---|
| Application level | HTTP header (server) | HTML tag (page) |
| Resource types | Any (HTML, PDF, images) | HTML pages only |
| How to add | Server config / .htaccess / code | Tag in <head> |
| Read by robot | Before page body is loaded | After HTML is loaded and parsed |
| Scope | Can be applied globally via URL patterns | Individually per page |
When to use X-Robots-Tag
- PDFs and documents: block technical PDFs, price lists, or contracts from indexing via server header
- Images: restrict preview display via
max-image-preview:nonefor copyright protection - Staging builds: block test environment from indexing with X-Robots-Tag: noindex at server level
- API responses: add noindex to JSON endpoints that Google may attempt to index
- Archival pages: block caching with noarchive without removing the page from the index
How to add X-Robots-Tag
- Apache (.htaccess):
Header set X-Robots-Tag "noindex, nofollow"— globally or conditionally - Nginx:
add_header X-Robots-Tag "noindex";in the location or server block - PHP:
header('X-Robots-Tag: noindex');before any output - Node.js/Next.js: via middleware or in the headers configuration in next.config.ts
- CDN: Cloudflare Workers or Rules allow adding headers without modifying the server
Common questions
Discuss your project?
Share your goals and website context — I will suggest a practical next step.