Webmaster Bench

Tools / Guides / How to test a robots.txt file before you publish it

How to test a robots.txt file before you publish it

A wrong robots.txt line can hide a whole section of a site from crawlers. You can check a draft against your real URLs first, with no Search Console access, if you know how the rules are chosen.

Published 2026-11-17. Last updated 2026-11-17. Written by Webmaster Bench; see About for how the guides are made and checked.

Try it: robots.txt Tester: Test whether Googlebot, Bingbot or AI crawlers may fetch a URL, and see which rule decides.

Why the draft needs testing, and why Search Console will not do it

Google's robots.txt report in Search Console shows "which robots.txt files Google found for the top 20 hosts on your site", when they were last crawled and any warnings. Google's help page also says it is only available for properties at the domain level, and the robots.txt page says "you can only use this report for robots.txt files that are already accessible on your site". It reports on a file that is already live. It does not let you try a draft. For checking whether an individual URL is blocked, Google's help points to the URL Inspection tool.

So the way to test a draft is to apply the matching rules to it yourself, or to paste it into a tester that applies them. The rules are short.

The rules a tester applies

  1. Pick the group. A crawler uses the group whose User-agent line names it, and ignores the others. If no group names it, it uses the * group, and if there is none, nothing is blocked (RFC 9309). Group order does not matter. The name is matched case-insensitively.
  2. Find the matching rules in that group. A rule matches a URL when its path is a prefix of the URL's path plus query string. * matches any run of characters and $ marks the end of the URL. Paths are case-sensitive and must start with / (Google).
  3. The most specific rule wins, which means the longest path. If an Allow and a Disallow tie, Allow is used. RFC 9309 says: "The most specific match found MUST be used", and for equivalent rules, "the allow rule SHOULD be used". Google states that in a conflict it uses the least restrictive rule.
  4. One exception in our tester: it reports /robots.txt itself as allowed, whatever the rules say.

Worked example: a draft with three bugs

A shop owner wants to hide the cart, the shop's internal pages and sorted listings from crawlers, and the checkout from Googlebot. This is the draft:

User-agent: *
Disallow: /cart/
Disallow: /shop
Disallow: /*?sort=

User-agent: Googlebot
Disallow: /checkout/

We pasted it into the robots.txt tester with eight URLs from the site. The tester's verdicts:

CrawlerResultURL pathDecided by
*Blocked/cart/line 2: Disallow: /cart/
GooglebotAllowed/cart/no rule in the googlebot group matches
*Blocked/shop/shoesline 3: Disallow: /shop
*Blocked/shop-guide/how-to-buyline 3: Disallow: /shop
*Blocked/shopping-listline 3: Disallow: /shop
*Blocked/products?sort=priceline 4: Disallow: /*?sort=
*Allowed/products?color=red&sort=priceno rule in the * group matches
GooglebotBlocked/checkout/payline 7: Disallow: /checkout/

On a narrow screen, swipe the table sideways for the other columns.

Three of these are not what the owner intended:

  1. /shop is a prefix, not a folder. It blocks /shop/shoes as intended, and also /shop-guide/how-to-buy and /shopping-list. The fix is Disallow: /shop/, with the trailing slash.
  2. Googlebot ignores the * group. Because the draft has a group naming Googlebot, Googlebot uses only that group, so /cart/ is allowed for Googlebot even though it is blocked for everyone else. Every rule meant for Googlebot has to be repeated in its group.
  3. /*?sort= only matches when sort is the first parameter. /products?color=red&sort=price is allowed. A second rule, /*&sort=, covers the other positions.

The corrected draft, with the same eight URLs:

User-agent: *
Disallow: /cart/
Disallow: /shop/
Disallow: /*?sort=
Disallow: /*&sort=

User-agent: Googlebot
Disallow: /cart/
Disallow: /shop/
Disallow: /*?sort=
Disallow: /*&sort=
Disallow: /checkout/
CrawlerResultURL pathDecided by
*Blocked/cart/line 2: Disallow: /cart/
GooglebotBlocked/cart/line 8: Disallow: /cart/
*Blocked/shop/shoesline 3: Disallow: /shop/
*Allowed/shop-guide/how-to-buyno rule in the * group matches
*Allowed/shopping-listno rule in the * group matches
*Blocked/products?sort=priceline 4: Disallow: /*?sort=
*Blocked/products?color=red&sort=priceline 5: Disallow: /*&sort=
GooglebotBlocked/checkout/payline 12: Disallow: /checkout/

On a narrow screen, swipe the table sideways for the other columns.

Now the cart, shop pages and both sort positions are blocked for both groups, and the two harmless URLs, /shop-guide/how-to-buy and /shopping-list, are allowed. The checkout stays blocked for Googlebot as well, because it is listed in that group. Notice that the test URLs were chosen on purpose: include URLs that must stay open as well as ones that must be blocked, because over-blocking is the common failure.

Advertisement

What a tester cannot tell you

  • Whether the file is served correctly. It must be named robots.txt, at the root of the host it applies to, as UTF-8 text (Google). After publishing, open it in a private window to confirm it is public. A browser-based tester works on the text you paste; it does not fetch your live file.
  • What a crawler does when the file is unreachable. RFC 9309 says that on a 4xx response the crawler "MAY access any resources on the server", and on a 5xx it "MUST assume complete disallow". Google treats 4xx errors (except 429) as if there were no file, and on persistent 5xx errors it first stops crawling, then falls back to the last good copy for up to 30 days.
  • How soon a change takes effect. Google's crawlers "update the cached version every 24 hours". Search Console's robots.txt report has a "Request a recrawl" function to speed that up. Other search engines have their own schedules.
  • Size. Google enforces a limit of 500 kibibytes and ignores content after it.
  • Anything besides crawling. robots.txt controls fetching. It does not control indexing or access; use noindex and authentication for those.

A routine that works

  1. Write the draft in a text file, not on the live server.
  2. List 10 to 20 real URLs: the ones that must be blocked, the ones that must stay open, and the ones that look similar to both.
  3. Run them through the tester once for each crawler that has its own group, plus once as an unnamed crawler for the * group.
  4. Publish, open /robots.txt in a private window, and re-test the live copy.

Sources

Advertisement