Check 04.03 · Indexing and canonicalization

Check meta robots and X-Robots-Tag

Audit and configure the meta robots tag and X-Robots-Tag header on Apache, Nginx, Cloudflare, CloudFront, WordPress, Shopify, Laravel or Next.js, with no conflicts.

Priority
Critical
Difficulty
Intermediate
Estimated time
1 to 3 h
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

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 noindex of 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 noindex in the header wins over an index in the tag.
  • Per-bot rules add up too. A generic nofollow and a noindex reserved for googlebot result in noindex, nofollow for 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 noindex from 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 noindex and Disallow on the same URL: remove the robots.txt rule for as long as you want the noindex to 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:

  1. Custom expression: (http.request.uri.path.extension eq "pdf") or starts_with(http.request.uri.path, "/merci").
  2. Operation: set a static header, name X-Robots-Tag, value noindex.
  3. 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

  • noindex and Disallow together: the bot never reads the noindex and the URL may stay indexed without content.
  • Two conflicting sources: the plugin writes index, the CDN adds noindex. The most restrictive one wins.
  • nofollow to “save crawl”: it protects nothing and cuts off discovery of the linked pages.
  • Counting on JavaScript to remove a noindex from the initial HTML: Google may not render a page marked noindex.
  • Putting noindex on paginated pages or categories to “concentrate” rankings: their links eventually stop being crawled.
  • Using noindex to 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 noarchive thinking 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.

Updated on

Topic checklist (PDF)

And now?

In the “Indexing and canonicalization” topic

  1. Check that the homepage is indexed
  2. Check strategic pages
  3. Check meta robots and X-Robots-Tag
  4. Remove accidental noindex tags
  5. Keep customer accounts and carts out of the index
  6. Handle internal search results with no SEO value
  7. Protect staging and private data with authentication
  8. Analyze pages discovered but not indexed
  9. Analyze pages crawled but not indexed
  10. Fix abnormal exclusions
  11. Fix soft 404s
  12. Check canonicals and absolute URLs
  13. Use self-referencing canonicals where relevant
  14. Align canonicals, sitemap and internal links
  15. Identify and consolidate duplicates
  16. Control parameterized URLs
  17. Standardize HTTP/HTTPS and www/non-www
  18. Compare declared and Google-selected canonicals
  19. Check Bing indexing
  20. Monitor indexing reports