In short
The <meta name="robots"> tag and the X-Robots-Tag HTTP header tell search engines whether they may index a resource, follow its links and show a snippet. The tag is for HTML pages; the header is for everything else (PDFs, images, feeds) and for rules set by the server or the CDN. Once the check is done, each page type carries the intended directives, a single source produces them, and no strategic page gets a noindex by accident.
Why it matters
Robots directives are read after crawling. The search engine downloads the page, finds the directive in the HTML or in the headers, then applies it. Three consequences:
- A page blocked by robots.txt does not show its directives. Google never sees the
noindexof a URL it is not allowed to crawl, and may index it without content if links point to it. - Sources add up. A theme, an SEO plugin, the server and the CDN can each add directives. Google combines the rules and applies the most restrictive one: a
noindexin the header wins over anindexin the tag. - Per-bot rules add up too. A generic
nofollowand anoindexreserved forgooglebotresult innoindex, nofollowfor Googlebot.
The same directives govern part of what Google’s generative features can reuse: nosnippet prevents snippets from being shown, including in AI Overviews and AI Mode, and max-snippet limits their length. These fine-grained settings are covered in check nosnippet, max-snippet and data-nosnippet (opens in a new tab). AI crawlers that do not build a search index are not bound by noindex: for them, robots.txt and access control are what count.
What it improves
- Controlled indexing Useful pages remain eligible, pages with no value (thank-you, cart, internal search results) leave the index.
- Non-HTML files Internal PDFs, export files or restricted images leave the results thanks to the header.
- Safer releases A centralized, tested directive prevents a global
noindexfrom being left in place by mistake. - Google snippets and AI answers Control over the length and presence of snippets. The effect on visibility is direct: a disallowed snippet reduces eligibility as a source.
- Rankings No direct effect; directives determine eligibility, not position.
How to check
HTTP header, on a page and on a PDF:
curl -sI https://example.com/ | grep -i "x-robots-tag"
curl -sI https://example.com/documents/catalogue.pdf | grep -i "x-robots-tag"
Tag in the HTML:
curl -s https://example.com/ | grep -i -o -E '<meta[^>]+name="(robots|googlebot|googlebot-news|bingbot)"[^>]*>'
Several robots tags on the same page point to several sources: theme and plugin, or plugin and hand-added code.
Rendered HTML: a directive added in JavaScript does not show up in curl. In Search Console’s URL Inspection, the “Indexing allowed?” line gives Google’s verdict; “View crawled page” shows the HTML and the headers received. Google reads the directives present after rendering, but a noindex tag in the initial HTML can prevent that rendering: do not count on JavaScript to remove it.
Site-wide: Screaming Frog shows the directives of each URL, tag and header combined, in the “Directives” tab, with a Noindex filter. The Robots Exclusion Checker extension for Chrome flags the tag, the header and the robots.txt of the open page.
Expected result: strategic pages have no restrictive directive, or at most index, follow; excluded pages have noindex from a single source; none of these excluded pages is blocked in robots.txt.
How to implement
Before you start
Directives recognized by Google:
| Directive | Effect |
|---|---|
all |
no restriction (default value, no need to write it) |
noindex |
excludes the page or file from results |
nofollow |
asks not to follow the links on the page |
none |
equivalent to noindex, nofollow |
nosnippet |
no text snippet or video preview, including in Search’s AI features |
max-snippet:[number] |
maximum snippet length in characters (0: none, -1: no limit) |
max-image-preview:[none, standard, large] |
maximum image preview size |
max-video-preview:[number] |
maximum video preview duration in seconds |
notranslate |
no translation offered in results |
noimageindex |
images on the page are not indexed |
indexifembedded |
allows indexing of content embedded in an iframe despite noindex |
unavailable_after:[date] |
removes the page from results after the given date |
Google now ignores noarchive, nocache and nositelinkssearchbox. Bing honors noindex, nofollow, nosnippet and the max-snippet, max-image-preview and max-video-preview directives; see its documentation for the others.
Formats:
<meta name="robots" content="noindex, follow">
<meta name="googlebot" content="nosnippet">
X-Robots-Tag: noindex
X-Robots-Tag: googlebot: nofollow
Ground rules:
- Tag for HTML, header for the rest. A PDF, an image or a CSV file has no
<head>. - A single source per page type: the SEO plugin, the template or the server, not all three.
- Never
noindexandDisallowon the same URL: remove the robots.txt rule for as long as you want thenoindexto be read. - No need to write
index, follow: it is the default behavior. Writing it has no effect but does no harm.
Inventory to draw up before touching the configuration:
| Page type | Target directive |
|---|---|
| Editorial pages, categories, products, services | none |
| Thank-you page, order confirmation | noindex |
| Cart, checkout, account | noindex, see keep customer accounts and carts out of the index (opens in a new tab) |
| Internal search results | noindex, see handle internal search results (opens in a new tab) |
| Internal PDFs, exports, working files | X-Robots-Tag: noindex |
| Staging | authentication first, see protect staging (opens in a new tab) |
Apache
Versions Apache 2.4.
Enable mod_headers (sudo a2enmod headers), then in the virtual host or the .htaccess:
<IfModule mod_headers.c>
# Office files and exports
<FilesMatch "\.(?:pdf|docx?|xlsx?|pptx?|csv)$">
Header set X-Robots-Tag "noindex"
</FilesMatch>
</IfModule>
For a whole directory, place Header set X-Robots-Tag "noindex" in a .htaccess inside that directory. For a URL generated by the application (not a file), use <If> in the virtual host:
<If "%{REQUEST_URI} =~ m#^/merci#">
Header set X-Robots-Tag "noindex"
</If>
sudo apachectl configtest && sudo systemctl reload apache2
Nginx
Versions Nginx 1.24 and later; add_header_inherit from 1.29.3.
location ~* \.(?:pdf|docx?|xlsx?|pptx?|csv)$ {
add_header X-Robots-Tag "noindex" always;
}
location ^~ /merci {
add_header X-Robots-Tag "noindex" always;
try_files $uri $uri/ /index.php?$query_string;
}
By default, an add_header in a location block cancels those inherited from the server block: repeat your security headers there, or, from Nginx 1.29.3 (and therefore on the 1.30 stable branch), place add_header_inherit merge; in the server block to combine the headers from both levels. The always parameter also adds the header to error responses. Reload with sudo nginx -t && sudo systemctl reload nginx.
LiteSpeed
Versions LiteSpeed Web Server (Enterprise) 6.x; OpenLiteSpeed 1.8 with the variant described below.
LiteSpeed Web Server (Enterprise) reads mod_headers directives from the .htaccess: the block from the Apache section works as is. Purge LSCache after the change.
OpenLiteSpeed reads only rewrite rules from the .htaccess and ignores Header directives. Add the header in the WebAdmin console: Virtual Hosts > (your host) > Context, new context of type Static, URI exp:^.*\.pdf$, location $DOC_ROOT/$0, accessible Yes, and in the Header Operations field the line set X-Robots-Tag noindex. Apply with Graceful Restart.
Caddy
Versions Caddy 2.x.
example.com {
@documents path *.pdf *.docx *.xlsx *.csv
header @documents X-Robots-Tag "noindex"
root * /var/www/example
file_server
}
Reload with sudo systemctl reload caddy.
IIS
Versions IIS 10 (Windows Server 2016 to 2025), URL Rewrite module 2.1 for the outbound rule.
For a folder, in the web.config at the site root:
<configuration>
<location path="documents">
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-Robots-Tag" value="noindex" />
</customHeaders>
</httpProtocol>
</system.webServer>
</location>
</configuration>
For a file extension, use an outbound rule from the URL Rewrite module:
<system.webServer>
<rewrite>
<outboundRules>
<rule name="Noindex PDF">
<match serverVariable="RESPONSE_X_Robots_Tag" pattern=".*" />
<conditions>
<add input="{REQUEST_URI}" pattern="\.pdf$" />
</conditions>
<action type="Rewrite" value="noindex" />
</rule>
</outboundRules>
</rewrite>
</system.webServer>
Cloudflare
Versions Cloudflare dashboard, Transform Rules, all plans, November 2026.
Open the Rules Overview, create a Response Header Transform Rule, then:
- Custom expression:
(http.request.uri.path.extension eq "pdf") or starts_with(http.request.uri.path, "/merci"). - Operation: set a static header, name
X-Robots-Tag, valuenoindex. - Deploy, then test with
curl -sI.
Also review existing rules: a rule of this kind left behind after acceptance testing is a classic cause of a global noindex.
AWS
Versions Amazon CloudFront console, response headers policies, November 2026.
CloudFront: in the CloudFront console, Policies > Response headers > Create response headers policy, in the custom headers section: add X-Robots-Tag with the value noindex and check the option to override the origin header. Attach the policy to a behavior whose path pattern is *.pdf or /documents/*. Then invalidate the cache for the path concerned.
S3 does not let you add an X-Robots-Tag header to objects: go through CloudFront.
Vercel
Versions vercel.json file, all Vercel plans, November 2026.
In vercel.json:
{
"headers": [
{
"source": "/documents/(.*)",
"headers": [{ "key": "X-Robots-Tag", "value": "noindex" }]
}
]
}
Vercel itself adds X-Robots-Tag: noindex to preview deployments: check that production does not inherit it.
Netlify
Versions _headers file, all Netlify plans, November 2026.
In the _headers file at the root of the publish directory:
/documents/*
X-Robots-Tag: noindex
WordPress
Versions WordPress 6.4 to 7.1 (wp_robots filter available since 5.7); Yoast SEO 20 and later or Rank Math 1.0.x.
An SEO plugin manages the tag per item and per content type: Yoast SEO (Advanced tab of each item, plus settings per content type and taxonomy) or Rank Math (Robots Meta). Keep only one. WordPress itself produces the tag through the wp_robots filter: noindex on internal search results, and noindex, nofollow everywhere if the visibility box in Settings > Reading is checked.
For a specific case without a plugin, in the site’s functionality plugin or a child theme’s functions.php:
add_filter('wp_robots', function (array $robots): array {
if (is_page('merci')) {
$robots['noindex'] = true;
$robots['follow'] = true;
}
return $robots;
});
Files in wp-content/uploads are served by the server without going through WordPress: for PDFs, use the rule from the Apache or Nginx section.
Shopify
Versions Shopify admin and Online Store 2.0 themes, all plans, November 2026.
Shopify does not let you add an HTTP header. For a page, product or article, use the seo.hidden metafield (value 1), which also removes the item from the sitemap. For a whole template, in Online Store > Themes > Edit code, file layout/theme.liquid, inside <head>:
{% if template contains 'search' %}
<meta name="robots" content="noindex">
{% endif %}
Drupal
Versions Drupal 10 and 11, Metatag module 2.x.
The Metatag module adds a “Robots” field per content type and per item, in its advanced settings. Check the global defaults in the module’s configuration.
Laravel
Versions Laravel 10 to 13.
A middleware with variadic parameters, to set the header per route group:
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class SetRobotsHeader
{
public function handle(Request $request, Closure $next, string ...$directives): Response
{
$response = $next($request);
$response->headers->set('X-Robots-Tag', implode(', ', $directives ?: ['noindex']));
return $response;
}
}
Route::middleware(SetRobotsHeader::class.':noindex,follow')->group(function (): void {
Route::get('/merci', [ThankYouController::class, 'show'])->name('thankYou');
});
Laravel splits middleware parameters on commas: the middleware joins them back together. For the tag, add a @stack('robots') inside <head> in the Blade layout and push the tag from the views concerned.
Next.js
Versions Next.js 15 and 16 (App Router).
With the App Router, the robots metadata produces the tag:
// app/merci/page.js
export const metadata = {
robots: {
index: false,
follow: true,
googleBot: { index: false, follow: true },
},
};
For the header, in next.config.js (the same headers() function can be written in next.config.ts):
module.exports = {
async headers() {
return [
{
source: '/documents/:path*',
headers: [{ key: 'X-Robots-Tag', value: 'noindex' }],
},
];
},
};
Avoid setting robots in app/layout.js: the value applies to every page that does not redefine it.
Nuxt
Versions Nuxt 4; same code on Nuxt 3, which is no longer maintained since July 2026.
In the page: useSeoMeta({ robots: 'noindex, follow' }). For a header per path, in nuxt.config.ts:
export default defineNuxtConfig({
routeRules: {
'/documents/**': { headers: { 'X-Robots-Tag': 'noindex' } },
},
});
Common mistakes
noindexandDisallowtogether: the bot never reads thenoindexand the URL may stay indexed without content.- Two conflicting sources: the plugin writes
index, the CDN addsnoindex. The most restrictive one wins. nofollowto “save crawl”: it protects nothing and cuts off discovery of the linked pages.- Counting on JavaScript to remove a
noindexfrom the initial HTML: Google may not render a page markednoindex. - Putting
noindexon paginated pages or categories to “concentrate” rankings: their links eventually stop being crawled. - Using
noindexto protect data: the page remains readable by everyone. Only authentication protects it. - Forgetting PDFs: without a header, an internal document linked just once can enter the index.
- Writing
noarchivethinking it affects Google: the directive has been ignored since the cache was removed.
Frequently asked questions
What is the difference between the meta robots tag and the X-Robots-Tag header?
The meta robots tag goes in the head of an HTML page; the X-Robots-Tag header is sent by the server with the HTTP response. The directives are the same. The header is essential for files without HTML, such as PDFs or images, and handy for setting a rule per directory from the server or the CDN. If both coexist, Google applies the most restrictive directive.
Can I set noindex and block the page in robots.txt?
No, that is counterproductive. A bot blocked by robots.txt does not download the page and therefore never sees the noindex directive: the URL may stay indexed, without content, if other pages link to it. Leave crawling open for as long as you want the noindex to be read. To save crawling on URLs with no value, choose one of the two methods, not both.
Does the noindex directive stop ChatGPT or Claude from reading my page?
No. The noindex directive asks a search engine not to show the page in its results; it does not prevent the page from being downloaded. AI crawlers are mainly controlled through robots.txt, each according to its user agent, and only server-side authentication really prevents reading. At Google, however, the nosnippet directive limits the reuse of the text in AI Overviews.
Should I write index, follow on every page?
No, it is not necessary. The absence of a meta robots tag is equivalent to index, follow, the default behavior of search engines. Writing it does no harm, but it multiplies the places to maintain. Reserve the tag for pages that need a restriction, such as noindex, nosnippet or max-snippet, and make sure a single source produces it for each page type.
Resources
- Google: Robots meta tag, data-nosnippet and X-Robots-Tag specificationsdevelopers.google.com
- Google: Block indexing with noindexdevelopers.google.com
- Bing: snippet control with robots tagsblogs.bing.com
- MDN: X-Robots-Tag headerdeveloper.mozilla.org
- Apache: mod_headers and Nginx: add_headerhttpd.apache.org
- Cloudflare: Response Header Transform Rulesdevelopers.cloudflare.com
- WordPress: wp_robots filterdeveloper.wordpress.org
- Shopify: Hide a page from search engineshelp.shopify.com
- Next.js: robots metadatanextjs.org
Updated on
Topic checklist (PDF)