Robots.txt and the meta robots tag tell search engine robots two different things. Robots.txt says "do not go in here" - it blocks crawling. Meta robots says "you may come in, but do not show this in the results" - it blocks indexing. They sound alike, but mixing them up is one of the most common SEO mistakes.
In short
- robots.txt - a file in the site's root that tells robots which addresses not to visit.
- meta robots (or the X-Robots-Tag header) - an instruction on the page itself, e.g. "do not index".
- Want a page out of Google? Use noindex and do NOT block it in robots.txt, or the robot will never see your noindex.
The sign on the gate and the stamp on the document
Picture an archive. A sign on the gate says "Warehouse B - no entry". That is robots.txt. A polite visitor (and Google's robots are polite) will not walk into warehouse B. But if someone tells them an interesting document sits in warehouse B, they may note that it exists - without knowing what is inside.
Meta robots is a "not for the catalogue" stamp on the document itself. The visitor can walk in, read the stamp and politely leave the document out of the catalogue. The catch: to see the stamp, they first have to reach the document.
robots.txt
A plain text file at yourdomain.com/robots.txt. Here is an example, close to what many WordPress sites have:
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://yourdomain.com/sitemap_index.xml
In other words: all robots (*) should stay out of the admin panel, except for one file, and the sitemap lives here.
What robots.txt is good for:
- keeping robots from wasting time on worthless addresses, such as internal search results or shop filters with thousands of combinations,
- pointing to your sitemap (Sitemap),
- blocking specific robots, e.g. those collecting content to train AI (GPTBot, Google-Extended and the like).
What it is NOT good for: hiding anything. The file is public, so writing Disallow: /secret-panel/ into it is effectively a signpost for the curious. And malicious bots ignore it anyway - it is a request, not a lock.
Meta robots
A tag in the page's head section:
<meta name="robots" content="noindex, follow">
Meaning: do not show this page in the results, but feel free to follow its links. The most common values are noindex (do not index) and nofollow (do not follow links). In WordPress you can set it without code, e.g. per post in the Yoast plugin.
What it is good for: thank-you pages after a purchase, search results, thin archives, test pages - anything that may exist but should not end up in Google.
X-Robots-Tag: meta robots for files
What about PDFs or images? They have no head section, so a meta tag cannot go in them. The same instruction can be sent as an HTTP header instead:
X-Robots-Tag: noindex
On an Apache server you set it in .htaccess - I walk through it step by step in Noindex in .htaccess. It works exactly like meta robots, but covers any file and even whole folders.
The trap: robots.txt plus noindex
A classic: a test page ends up in Google. Someone adds noindex and, "just to be safe", blocks it in robots.txt as well. The result? The robot cannot enter the page, so it never sees the noindex - and the address stays in the index, sometimes with a note that no description is available.
So the order is:
- Add
noindex(the meta tag or the header) and leave the page open to robots. - Wait until Google visits again and drops it from the results. You can speed that up in Search Console by asking it to re-check the URL.
- Only then, if you like, block it in robots.txt. And if the page is meant to disappear for good, it is better to delete it and return a 410 (more in 301, 410 and noindex redirects).
How to check
- The robots.txt report in Google Search Console shows which version of the file Google sees and whether it has errors.
- URL Inspection in Search Console tells you whether a specific page is blocked, has noindex and is in the index.
- Your browser's developer tools (F12, the Network tab) show the X-Robots-Tag header on any file.
Summary
- You want robots to stay away from addresses - robots.txt.
- You want a page out of the results - noindex in a meta tag.
- You want the same for files and folders - the X-Robots-Tag header.
- You want to truly hide something - a password, not any of the above 🙂