robots.txt is a small text file at your domain root that tells crawlers which URLs they may fetch. It controls crawling, not indexing — a page blocked in robots.txt can still be indexed if other sites link to it. This guide covers the rules, the mistakes, and how to test your file.
How robots.txt works
Crawlers read /robots.txt before requesting any page. The file contains user-agent groups and allow or disallow rules. Googlebot, Bingbot, and AI crawlers like GPTBot and ClaudeBot all respect it. If the file is missing or empty, everything is allowed by default.
Writing correct rules
Order matters: the most specific matching rule wins. Wildcards support * for any characters and $ for end-of-line. Never block CSS or JavaScript files — Google needs them to render your pages. Block only private areas: admin panels, account pages, internal search results, and staging environments.
robots.txt versus noindex
robots.txt blocks crawling; the robots meta tag blocks indexing. If a page is blocked in robots.txt but has no noindex, search engines can still index it from external links without ever seeing your directive. To remove a page from the index, use noindex — not robots.txt.
AI crawlers
Answer engines use their own user-agents: GPTBot, ClaudeBot, CCBot, Google-Extended, PerplexityBot. If you want your content cited in AI answers, do not block them. Test your file against every crawler with the live tester.
Testing your file properly
A robots.txt that looks correct in a text editor can still block the wrong things. The live tester simulates each crawler's user-agent against a specific URL and returns the matching rule — catching mistakes like a Disallow: / that accidentally blocks everything, or a wildcard that matches more paths than intended. Test your homepage, your top money page, and your sitemap reference after every edit.
Common production mistakes
Four mistakes appear in nearly every broken robots.txt we audit: blocking CSS and JavaScript directories (Google needs them to render), leaving staging Disallow rules in production files, missing the Sitemap directive entirely, and creating conflicts with noindex tags on the same pages. Each is invisible until a crawler hits it — which is exactly when it becomes expensive.
AI crawler policy decisions
Decide deliberately which AI crawlers you welcome. Sites that want citations in ChatGPT, Perplexity, and AI Overviews should explicitly allow GPTBot, ClaudeBot, CCBot, Google-Extended, and PerplexityBot. Sites protecting premium content may block them — but should understand that blocking removes the site from AI answers entirely, not just from training data.
A production-safe robots.txt, line by line
Most sites need a short file. This example allows public content, keeps private areas out of the crawl, and points to the sitemap:
User-agent: *
Allow: /
Disallow: /admin/
Disallow: /account/
Disallow: /search?
Disallow: /staging/
Sitemap: https://example.com/sitemap.xml
Keep the sitemap directive absolute and on its own line. Do not add a crawl-delay unless you have a specific reason and have tested it with the crawler you care about. If you run a staging host, make sure its robots.txt blocks everything before the first public request, not after launch.
A 15-minute robots.txt test
- Fetch
/robots.txtfrom the production host and confirm it returns 200 astext/plain. - Test the homepage, a top money page, a blog post, and one asset URL with the live tester.
- Check that Googlebot can fetch CSS and JavaScript needed to render the page.
- Confirm the sitemap URL in the file returns valid XML.
- Test at least one AI crawler if AI citations are part of your strategy.
Run the test after every deploy that touches routing, middleware, or the public directory. A single catch-all rule can block the whole site while returning a perfectly valid text file.
What to do when a deploy blocks the site
If rankings or impressions drop immediately after a release, fetch robots.txt before changing content. If it contains an unexpected Disallow: /, fix the file and request a recrawl of the homepage and key landing pages. Then check the server logs for crawler requests that returned 403 or 503. Restore access first; content changes can wait until crawl access is confirmed.
Free tools in this hub
- Robots.txt checker — Validates syntax, rules, and crawl directives on any live site
- Robots.txt generator — Builds a correct robots.txt from simple choices
- Robots.txt live tester — Tests whether a specific URL is allowed for each crawler
- Robots vs noindex conflict checker — Finds contradictions between robots.txt and meta robots
- AI robots.txt explainer — Explains what your file means for AI crawlers
Frequently asked questions
Where does robots.txt have to live?
At the domain root: https://example.com/robots.txt. A file in a subdirectory is ignored by crawlers.
Can robots.txt stop a page from being indexed?
No. It stops crawling. If other sites link to the page, search engines can still index the URL from those links. Use a noindex tag to control indexing.
Should I block AI crawlers?
Only if you do not want your content cited in AI answers. Blocking them removes your site from ChatGPT, Perplexity, and AI Overview citations entirely.