Robots Meta Tag vs X-Robots-Tag: Controlling Indexing Correctly
Sometimes a page should exist for users but stay out of search results: thank-you pages, internal search results, staging copies or downloadable files meant only for customers. The robots meta tag and the X-Robots-Tag HTTP header are the two ways to give search engines indexing instructions. They support the same directives but work in different places.
The Robots Meta Tag
The robots meta tag sits in the HTML head of a page:
<meta name="robots" content="noindex, follow">
It is the simplest option for HTML pages and can usually be controlled per page in a CMS. You can also target one crawler by replacing robots with a specific name, such as googlebot.
The X-Robots-Tag Header
The same directives can be sent as an HTTP response header:
X-Robots-Tag: noindex
Because headers work for any file type, this is the method to use for PDFs, images, spreadsheets and other non-HTML resources. It is also convenient for applying rules to whole folders or file types from the server configuration.
Apache example for PDFs
<FilesMatch "\.pdf$">
Header set X-Robots-Tag "noindex"
</FilesMatch>
Nginx example
location ~* \.pdf$ {
add_header X-Robots-Tag "noindex";
}
Laravel middleware example
return $next($request)->header('X-Robots-Tag', 'noindex');
Common Directives
- noindex: do not show this page in search results.
- nofollow: do not follow links on this page. Rarely needed on your own site.
- none: equivalent to noindex, nofollow.
- nosnippet: do not show a text snippet or video preview.
- max-snippet, max-image-preview, max-video-preview: limit how much of the page appears in results.
- noimageindex: do not index images on this page.
- unavailable_after: stop showing the page after a given date, useful for time-limited offers.
Robots Directives vs robots.txt
This is the most common source of confusion. Robots.txt controls crawling; robots directives control indexing. If robots.txt blocks a URL, search engines cannot fetch it and therefore cannot see its noindex tag. A blocked URL can still appear in results, without a description, if other pages link to it.
To remove a page from results, allow crawling and use noindex. Only block it in robots.txt after it has dropped out of the index, and only if you need to save crawl resources. Our guide to robots.txt for crawling covers the crawling side.
Pages That Usually Need noindex
- Form confirmation and thank-you pages.
- Internal site search results.
- Login, account and cart pages.
- Thin tag or filter pages with no search demand.
- Staging and development environments, ideally also protected by a password.
Mistakes to Avoid
- Leaving noindex on after launch: staging settings copied to production can remove a whole site from search. Add a launch check.
- Noindex on pages listed in the sitemap: sitemaps should list only indexable URLs, as explained in our XML sitemap guide.
- Mixing noindex with a canonical to another URL: see our canonical tags guide for why this sends conflicting signals.
- Conflicting header and meta values: when both exist, search engines apply the most restrictive. Keep one source of truth.
How to Check Directives
Use the URL Inspection tool in Search Console to see whether indexing is allowed. To see headers, open your browser's developer tools, select the Network tab and inspect the response headers of the document or file. Crawling tools can report both meta and header directives across a whole site.
Need indexing rules implemented cleanly across templates and file downloads? Our web development team builds them into Laravel and WordPress projects.
Frequently Asked Questions
Is noindex the same as blocking in robots.txt?
No. Noindex stops indexing but needs crawling to be seen. Robots.txt stops crawling, which can prevent search engines from seeing a noindex directive.
How do I noindex a PDF?
Send an X-Robots-Tag: noindex HTTP header for the file, because PDFs cannot contain an HTML meta tag.
How long does noindex take to work?
The page drops out after search engines recrawl it, which can take days or weeks depending on how often the page is crawled.
Comments
Comments appear after admin approval.