Guide · Crawling
Robots.txt mistakes that block useful pages
Robots.txt is a plain text file at the root of a site. It gives cooperative crawlers instructions about which paths they may request. It is not a password wall, and it is not a reliable way to remove a private file from the internet.
Most robots.txt problems are not exotic. A site blocks a folder for staging, forgets to remove the rule, and later publishes the public pages inside that folder. Or a template adds Disallow: / and the whole site disappears from crawling. This guide shows the common mistakes and a test you can repeat.
How a group works
A group starts with one or more User-agent lines. The Allow and Disallow lines that follow apply to that group. A Sitemap line is a global pointer to an XML sitemap, not a rule inside the group.
The example asks all crawlers not to request /private/, but permits the public subsection /private/public/. The sitemap line tells crawlers where the XML sitemap is.
Five mistakes that block useful pages
1. Disallow: / on a public site
Disallow: / blocks the whole site for the selected group. It is sometimes copied from a staging template and left in production. The result is a site that crawlers are asked not to request at all.
2. Blocking CSS or JavaScript
If a crawler cannot fetch the CSS or JavaScript that shapes the page, it may see a different page than a visitor. Google's documentation asks site owners to check whether blocking these resources prevents the crawler from rendering the page correctly. Blocking a whole asset directory to "save crawl budget" is usually a bad trade.
3. Empty Disallow
An empty Disallow: does not block anything. It is often left behind after a path is removed. It adds noise, and it can hide the fact that a real rule was deleted.
4. Duplicate or contradictory rules
Two identical rules are harmless to many crawlers but make the file hard to audit. A Allow: / next to a Disallow: / is worse: the file says two opposite things, and the reader has to know which rule wins.
5. Treating robots.txt as access control
A disallowed URL can still be linked, discovered, requested directly or seen by a crawler that ignores the file. If a file must be private, use authentication, a signed URL or server permissions. Robots.txt only guides cooperative crawlers.
Allow, Disallow and the longest match
The common matching model is: choose the most specific group for the crawler, find the longest matching rule, and let Allow win a tie against a Disallow of the same length. Wildcards * and the end anchor $ are supported by major crawlers, but implementations can differ.
| Rules | Path | Typical result |
|---|---|---|
Disallow: /private/Allow: /private/public/ | /private/public/page | Allowed, because the Allow rule is longer |
| Same rules | /private/draft | Blocked by the Disallow |
Disallow: /*.pdf$ | /guide.pdf | Blocked by the anchored wildcard |
| No matching rule | /about | Allowed by default |
Robots.txt, noindex and authentication
These are different tools with different jobs. Mixing them up is a common source of "the page is gone but the URL still appears" reports.
| Tool | What it does | What it does not do |
|---|---|---|
| robots.txt | Asks a cooperative crawler not to request a path. | Does not hide a URL from links, browsers or crawlers that ignore the file. |
| noindex | Asks a search engine not to show the page in results. | Does not stop a person from opening the page; the crawler must be able to fetch it to see the directive. |
| Authentication | Requires a login or another credential. | Does not automatically remove an already indexed URL; handle that separately. |
If a page should not appear in search results, use noindex and make sure the page is crawlable. If a file must be private, use authentication. If you only want to reduce crawling of a low-value path, robots.txt may be enough.
How to test a robots.txt change
- Edit the file locally. Use the builder or a text editor. Keep one intent per group.
- Parse the result. Paste it into the inspector. Look for duplicate rules, empty rules,
Disallow: /and a relative sitemap URL. - Test the paths that matter. Test the home page, a public article, the asset directory and the private folder. Confirm the longest matching rule.
- Deploy and fetch the live file. Open
https://your-domain/robots.txtand compare it with the local copy. A CDN or host panel can serve a different file. - Check the crawler documentation. If a rule depends on wildcards or group selection, read the specific crawler's documentation. The model is not a promise.
What the tool cannot tell you
- How every crawler implements wildcards, group selection or redirects.
- Whether a crawler will honor the file at all.
- Whether a URL has been discovered through a link, a sitemap or another source.
- The live response, server status or a WAF rule.
- Whether the page is indexed. Robots.txt controls crawling, not indexing directly.
Sources
- Google Search Central, Robots.txt introduction and guidelines, accessed 2026-11-23.
- Google Search Central, Create and submit a robots.txt file, accessed 2026-11-23.
- Google Search Central, Block indexing with noindex, accessed 2026-11-23.