This guide answers: robots.txt: syntax, common mistakes and how to test it
Robots.txt: syntax, common mistakes and how to test it
Learn how robots.txt works, where the file must live, the directives to use and the mistakes that block your site, plus free ways to test it before launch.
By Hannah Wells, Technical SEO, site performance and online stores
· 6 min read
updated

Short answer
A robots.txt file is a plain text file at the root of your domain that tells crawlers which paths they may fetch. It is built from groups of rules, each starting with a User-agent line followed by Disallow or Allow directives. The most damaging mistakes are a misplaced file, a stray slash that blocks the whole site, blocked CSS and JavaScript, and a staging file pushed to production. You can check all of them for free before they cost you anything.
Key points
- Robots.txt is a text file that tells crawlers which pages they can access.
- Allow permits a path, and it cancels a broader Disallow.
- User-agent: * Disallow: / A single slash after Disallow blocks the entire site for the targeted bot.
- Robots.txt controls crawling. When a path is disallowed, Googlebot does not access the page.
Location: /robots.txt at the domain root. Blocks: crawling, not indexing. Never supported by Google: Crawl-delay. Standard behind the official parsers: RFC 9309. Details checked on 03/12/2026.
What robots.txt is and where it has to live
Robots.txt is a text file that tells crawlers which pages they can access. Its format is simple: rules are organised in groups, and each group is tied to a User-agent, meaning the bot it addresses. Under that line you list Disallow or Allow directives, each followed by a URL path.
Placement is the first thing to get right. The file must sit at /robots.txt on the root of the domain. A file at /blog/robots.txt or /public/robots.txt is ignored. Crawlers do not search folders for it, so a perfectly written file in the wrong place does nothing at all.
This catches people who work with a CMS or a build pipeline. The file may exist, open fine in an editor and still be invisible to bots because it was saved in a subfolder. The quickest sanity check is to load the root address followed by /robots.txt in a browser and confirm you see your rules.
/robots.txt
/blog/robots.txt/public/robots.txt
The essential directives and their syntax
Four directives do almost all the work.
- User-agent names the bot the group applies to.
- Disallow blocks a path.
- Allow permits a path, and it cancels a broader Disallow.
- Sitemap points to your XML sitemap.
Here is a small file that uses all four:
User-agent: *
Disallow: /admin/
Allow: /admin/help/
Sitemap: https://example.com/sitemap.xml
The group starting with User-agent: * addresses every bot. If you write User-agent: Googlebot instead, the rules below it apply to that crawler only. Use the wildcard group for general rules and a named group when one bot needs different treatment.
The Allow line in the example shows the hierarchy. The Disallow blocks the whole admin folder, and the Allow carves out one path inside it. A narrower Allow wins over a broader Disallow for the same path.
Two special characters help you match patterns. The asterisk * stands for anything. The dollar sign $ marks the end of a path. Both are easy to misplace, which is why a validator is worth running whenever you use them. Validators specifically flag wildcards that are malformed.
Syntax errors that break everything
The most dangerous line in the whole format is also one of the shortest:
User-agent: *
Disallow: /
A single slash after Disallow blocks the entire site for the targeted bot. Compare it with Disallow: /page, which blocks only paths that start with that string. The two lines look almost identical and behave completely differently. If a site suddenly stops being crawled, check for this line before anything else.
Other slips are quieter:
- Forgetting the leading slash, so you write
Disallow: adminwhere you meantDisallow: /admin. - Leaving stray spaces or misplaced characters in a line.
- Writing Allow and Disallow rules that conflict with each other.
- Omitting the Sitemap directive. It is recommended, and it is commonly forgotten.
Validators check for exactly these categories: syntax errors, Allow and Disallow conflicts, malformed wildcards, and Sitemap directives that are missing or badly formed.
What robots.txt does and does not do
Robots.txt controls crawling. When a path is disallowed, Googlebot does not access the page. That is the whole job.
It does not control indexing. Noindex, set in a meta tag or an HTTP header, blocks indexing: the page is crawled but not indexed. The two tools solve different problems, and mixing them up produces fixes that do nothing. Putting noindex inside robots.txt does not work.
Stops the bot from accessing the page. Crawling.
Page is crawled, but kept out of the index. Indexing.
Two more limits are worth knowing. Google has never supported the Crawl-delay directive, so adding it for Google achieves nothing. And robots.txt cannot block AI bots selectively unless you write a group for a specific User-agent. Blocking AI crawlers is a topic of its own, and the behaviour of those bots is still moving, so this page does not go further.
Blocking mistakes that do real damage
Blocking CSS and JavaScript is common and harmful. Google needs those resources to render and understand your pages. If they are disallowed, Google cannot see the page as a visitor does. Review any rule that covers script or style folders and ask whether it is really needed.
Deploying a staging robots.txt to production is the second classic. Staging environments often block everything on purpose. If that file travels with the release, the live site inherits a full block. Make the robots.txt file part of your deployment checklist, and look at the live file right after every release.
The third is blocking the entire site during maintenance and forgetting to lift it. It is the same Disallow: / problem, just reached by a different route.
How to test your robots.txt
Test before you deploy, not after. Several free tools let you do it.
- Google Search Console has a built-in robots.txt tester. It checks any URL against your live file.
- Bing Webmaster Tools offers a tester among its tools.
- The robotstxt.com tester is a third-party tool. It is not an official Google product.
- The Merkle robots.txt tester gives a quick check without connecting to Search Console.
The official-style testers use the robots.txt parser that Google open-sourced, and they follow RFC 9309. That makes their verdicts a reasonable proxy for how a major crawler reads your rules.
The process is the same in most tools:
the absolute site URL and pick a User-agent
the live robots.txt
the content, or edit it to try a change
see whether each is allowed or blocked
Choose paths that matter: your key templates, a few product or article URLs, and your CSS and JavaScript folders. Then run the validation view to catch syntax errors, conflicts and Sitemap problems in one pass.
Good habits to keep
Include at least one Sitemap line so crawlers find your XML sitemaps. Test every change before it goes live. Review the file after any restructuring of the site, since old paths and new ones may no longer match your rules. Keep an eye on Google Search Console for errors it reports about the file.
Where the evidence stops
Some questions have no reliable answer yet, and it is better to say so than to guess.
- We found no trustworthy figure for how many sites have a misconfigured robots.txt, so we make no claim about how widespread these errors are.
- Google says blocked CSS and JavaScript make pages render less well, but it gives no metric for the SEO impact.
- How AI bots treat robots.txt rules in 2026 is unsettled, with no stable official position to cite.
- How fast crawlers react after you fix a mistake depends on crawl budget and varies case by case.
Nothing here promises rankings or traffic. A correct robots.txt removes a way to hurt yourself. It does not, by itself, make a page perform.
- DynoMapper, guide to the robots.txt file
- robotstxt.com, robots.txt tester
- EngTools, robots tester
- WuTools, robots.txt tester
- Relevant Audience, robots.txt guide
- SiteRadar, complete robots.txt configuration guide


