Skip to content
Book a call

robots.txt groups replace, they do not extend

· 3-minute read · Measurement and growth · by Direct Softworks

Give one crawler its own block and it stops reading the default one entirely. Which means the crawler you singled out is the only one allowed into your admin panel.

Here is a robots.txt that does the opposite of what its author intended.

User-agent: *
Disallow: /admin
Disallow: /portal
Disallow: /api

User-agent: Google-Extended
Allow: /

The intent is obvious: keep everyone out of three private areas, and additionally let Google's AI crawler in. Read it aloud and it sounds right.

What it actually says is that Google-Extended may crawl /admin.

The rule

A crawler uses exactly one group: the most specific one matching its name. Not the union of the matching groups. One.

So Google-Extended reads its own block, finds Allow: /, and never looks at the * block at all. The three disallows do not apply to it. Every other crawler reads the * block and is correctly excluded.

The single most useful sentence about robots.txt is this one: a matched group replaces the default, it never extends it. Anything you want to apply to a named crawler has to be repeated inside that crawler's group.

The corrected version:

User-agent: *
Disallow: /admin
Disallow: /portal
Disallow: /api

User-agent: Google-Extended
Allow: /
Disallow: /admin
Disallow: /portal
Disallow: /api

Verbose, and correct.

Why this is so easy to get wrong

Because it reads like CSS, or like configuration inheritance, or like almost every other layered system a developer touches. Everywhere else, a more specific rule adds to a general one. Here it replaces it.

And the failure is completely silent. The file is valid. No tool complains. The only way to find out is to reason about it deliberately, or to have somebody find your admin panel in an AI answer.

There is a second version of this that has nothing to do with syntax.

Several CDNs, Cloudflare among them, offer a managed robots.txt that prepends a block to whatever your origin returns. Turn it on and your served file is two files stapled together, with the managed one first.

That block is all or nothing. In Cloudflare's case it disallows nine AI crawlers, and there is no per-crawler setting anywhere in the API. So if you want to allow exactly one of them, say Google-Extended because you are happy for Gemini to train on and ground answers in your pages, you cannot. The toggle blocks all nine or none.

Which means the actual decision is: turn the managed block off and write the policy yourself, in your repository, where it can be reviewed in a diff and tested. That is what we did. The file being generated rather than hand-edited also means it cannot be silently stale behind a cache, which is the other way a crawler policy quietly stops being the one you think you published. The tell that somebody has turned it back on is a BEGIN Cloudflare Managed content header appearing in your live file.

Content signals are a different layer

Worth separating, because they get conflated.

Disallow controls access. Content-Signal, from the contentsignals.org convention, states permitted use, and under Article 4 of the EU copyright directive it operates as an express reservation of rights.

User-agent: *
Content-Signal: search=yes, ai-train=no, use=reference
Allow: /

That is not contradictory. It says: read this, index it, cite it, do not train on it. You are not technically blocking anyone and you are declining to grant a right. Those are different statements and a site can coherently make both.

Google ignores the line and reports it in Search Console as an unknown directive. That is expected, not a defect. It is not addressed to Googlebot.

Test it, do not read it

Reading a robots.txt and believing you have understood it is how the bug at the top of this article ships. Parse it the way a crawler does.

We keep a check in the test suite that builds the file, parses it into groups, and asserts two things: that no user-agent is blocked outright, and that every group which is allowed in still carries the private-path disallows. That second assertion is precisely the bug this article is about, and it is the sort of thing that is trivial to test and impossible to notice by eye.

More notes