noindex vs robots.txt: Which Way to Remove a URL
There are two files on your server that both appear to mean "keep this page out of Google". One of them does. The other one does not, cannot, and never has, and the confusion between them is the single most expensive misunderstanding in day-to-day technical SEO. It costs a URL its traffic for six months while everybody congratulates themselves on the fix. This post is a decision guide: what each mechanism actually does, when each one fails, and how to pick without guessing.
Neither is a purge button, and that matters for expectations as well as for mechanics. Removal takes a recrawl to take effect, the recrawl has to find the URL, and neither of those happens on a schedule you control. The right choice is still worth making today, because the cost of choosing wrongly is paid every month.
The short version. noindex is an instruction delivered inside the page, and it is the only thing that reliably removes a URL from the index. Disallow is an instruction delivered before the page, and it only stops the fetch. Choose noindex when you want the URL out of the index but the page kept. Choose a 410 when you want the URL to stop existing. Choose Disallow when you want the crawler to stop wasting requests on something that will never be indexed anyway.
The two mechanisms side by side
robots.txt Disallow | noindex on the page | |
|---|---|---|
| Who reads it | The crawler, before the fetch | The crawler, after the fetch |
| Effect on crawling | Stops the fetch entirely | Nothing |
| Effect on indexing | None | Removes the URL from the index |
| Works on a new URL | Yes, prevents it ever being indexed | No, the tag must be seen first |
| Works on a URL already indexed | No | Yes, once the crawler sees it |
| Leaves the page reachable to users | Yes | Yes |
| Stops the crawler finding the tag | Yes, permanently | No |
| Right for staging and cart | Yes | No, a block is cheaper |
| Right for pages that must keep working | No | Yes |
The third row is the one people forget. Disallow does not remove a URL from the index. It removes the crawler's ability to notice that it should be removed. A URL that was indexed before the block was added stays in the index, and it stays there as a bare link with no snippet, because nothing is going back to check.
Three ways to apply noindex
The meta robots tag
The common form, in the head of the page. Simple, visible, and it only works if something actually fetches the page.
<meta name="robots" content="noindex">
<meta name="robots" content="noindex, nofollow">
The X-Robots-Tag header
The same instruction delivered by the server, which makes it the better option when you cannot control the template. It also works for files that are not HTML, such as PDFs, which is why it is the usual answer for a document library.
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
X-Robots-Tag: noindex, nofollow
Cache-Control: no-cache
In nginx it can be applied without touching the application:
location /archive/ {
add_header X-Robots-Tag "noindex, nofollow" always;
try_files $uri $uri/ =404;
}
robots.txt Disallow, which is not really a way to apply noindex
This is the third thing people put in the list of ways to deindex, and it is the weakest of the three by a wide margin. It is listed as a method of removal in a great deal of SEO material and it does not remove anything.
User-agent: *
Disallow: /archive/
Disallow: /old-blog/
If a URL is blocked and not yet indexed, this file is the most efficient way to keep it that way. If a URL is blocked and already indexed, it is the least efficient, because the instruction that would have removed it is now sitting inside a page the crawler is not allowed to read.
The crawl-before-noindex trap
Here is the mechanism, in full, because it explains both failure modes.
A crawler fetches the URL, reads the directives inside the page, and applies them. So for noindex to have any effect, the crawler must first fetch the page. If the same URL is also blocked in robots.txt, the fetch never happens. The noindex is never read. The URL stays in the index.
That is the trap, and it has a nasty side effect: the situation is invisible to your own audits, because your crawlers obey robots.txt too. Once the block goes in, the URL disappears from your crawl reports as well as from your remediation list, and it now looks clean. In a PruneSEO inspection the result is labelled NOINDEX_BLOCKED, which is a blocked result rather than an indexed one, and it sits under Other findings with robots exclusions and soft 404s because the sample did not resolve to one verdict. It is not a clean page. It is an unmeasured page.
The way out of the trap is always the same, and it is a little counter-intuitive: to remove a URL from the index you have to let the crawler fetch it, at least once, with the instruction visible.
- Remove the
Disallowline for that path. - Make sure the
noindexis served, as a meta tag or as anX-Robots-Tagheader. - Keep the URL reachable and internally linked for long enough to be recrawled, or submit it through the URL Inspection tool.
- Confirm the index entry is gone before you put the block back, if you want the block back.
Pages that must stay reachable for users
This is the situation noindex was designed for and where it is clearly correct. A price comparison page that only functions with a cookie set by an affiliate. An archive page kept alive for a link from a partner or an old press release. A members area that must load for signed-in users but should never appear in results. A paginated archive whose pages hold no unique value.
In each of these cases a 410 is wrong because the page has to keep working, and a Disallow is wrong because it stops the crawler seeing the instruction and freezes whatever Google already knows. The noindex keeps the page fully functional for people and removes it from the index.
# robots.txt after the URL has been removed from the index
User-agent: *
Disallow: /internal-search/
Disallow: /cart/
Allow: /
Sitemap: https://example.com/sitemap.xml
And the directive list applied to the pages themselves:
# X-Robots-Tag directives, one per retired pattern
/compare/* -> noindex, nofollow
/archive/2019/* -> noindex
/members/* -> noindex, nofollow
Where the platform cannot serve a header on a specific route, the equivalent is a meta tag injected by the template layer, and it must be verified on a live response rather than assumed from the code.
Verify the directive actually arrives
Every one of these approaches fails in the same way, which is silently. A rule is written into a config file, the deploy finishes, the ticket is closed, and the header never reaches the response because a CDN in front of the origin strips it, because a cache is serving an older copy, or because the route matched a broader block that returns early. Nothing errors. The page still returns 200 and still looks fine.
So check the actual response, not the configuration. Fetch the URL and read the response headers. If X-Robots-Tag is not there, nothing else you believe about that route is worth much. Two habits make this reliable: check from outside your network, because internal requests can bypass the CDN entirely, and check more than one URL in the pattern, because rules that work on the first route frequently miss the ones below it. Do it again after the cache has expired, because a header that was correct on a cold fetch and absent on a warm one is its own kind of bug.
The same discipline applies to the meta tag. View source on a live page rather than reading the template, because the two are not the same thing once a layout, a block or a consent layer is involved.
A decision guide
Work down the list and stop at the first match.
- The page must keep working for users, and should not appear in results:
noindex, served and confirmed. - The page has no value, will never have value, and can be retired: a 410, which stops the rechecking as well.
- The page should be replaced by a better one: a 301 to the replacement, not a
noindex. - The area should never be crawled at all, such as staging, cart or an unbounded parameter space:
Disallowin robots.txt. - The page is duplicated by a better version elsewhere: a canonical pointing at the better version, not a
noindex.
If you find yourself wanting noindex and Disallow on the same URL, stop. One of them is wrong and the combination guarantees the page stays in the index forever.
Where to go next
Pick the mechanism from the table rather than from habit, write the change down as a file, and have whoever runs the server apply it. PruneSEO generates a noindex directive set and a robots.txt fragment as artifacts alongside the redirect CSV and the canonical manifest, so the decision and the implementation stay in one place. It does not change your site, and no tool can guarantee that Google will act on any of this, so the follow-up step is always to re-inspect and confirm rather than to assume. The decision behind robots.txt itself is covered in robots.txt Is Not an Indexing Directive, and the User Guide covers how the files are produced.