Skip to content
Technical SEO 4 min read

Robots.txt: How to Control Crawlers Without Blocking Rankings

Robots.txt rules explained: allow and disallow syntax, robots.txt versus noindex, and how to keep AI crawlers welcome. Free validators included.

Robots.txt: How to Control Crawlers Without Blocking Rankings
Key takeaways
  • robots.txt controls crawling, not indexing; use noindex to remove pages from search.
  • The most specific matching rule wins, so test the exact URL and user-agent.
  • Never block CSS, JavaScript, or key landing pages by accident.

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

  1. Fetch /robots.txt from the production host and confirm it returns 200 as text/plain.
  2. Test the homepage, a top money page, a blog post, and one asset URL with the live tester.
  3. Check that Googlebot can fetch CSS and JavaScript needed to render the page.
  4. Confirm the sitemap URL in the file returns valid XML.
  5. 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

Related reading: Schema markup guide.

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.

Share X LinkedIn Email
Want a quick SEO check on a page? Run the free SEO checker and get a scored report with prioritised fixes.
Free SEO checker

Reviewed by TheLinksMaster

SEO Editorial Team

Our editorial team tests every tool and guide on this site against real websites. We update content when search algorithms change so you always get current, practical SEO advice.

How we test and update our guides · Meet the editorial team

Start with these guides

Canonical Tags Explained: The Complete Guide A complete guide to canonical tags - what they are, why they matter, how to impl... Core Web Vitals Explained: Improve LCP, INP, and CLS A practical guide to Core Web Vitals - what LCP, INP, and CLS measure, how to te...
Free DNS lookup Lookup the list of DNS records for a domain. Inspect A, CNAME, MX, TXT, and… Free Meta tags checker Analyze the meta tags information of a URL. Review titles, descriptions… Free Robots.txt checker Inspect the robots.txt rules and sitemap declarations of a domain. Verify… Free Structured data checker Detect JSON-LD and Microdata structured data on a page URL. See which schema… Free Robots meta checker Inspect robots meta tags and X-Robots-Tag response headers on any page… Free Meta tags extractor Extract all meta tags from a page URL in one place. Review titles…
Redirects: 301, 302 and How to Kill Redirect Chains Redirect guide: which code to use, how chains and loops waste crawl budget, and... Schema Markup: JSON-LD Formats That Earn Rich Results Schema markup guide: which JSON-LD formats matter in 2026, how to implement and... XML Sitemaps: Creation, Splitting and Coverage Checks Build and maintain XML sitemaps that work: URL limits, lastmod accuracy, sitemap... Meta Tags: The Complete Guide to Titles, Descriptions and Robots Everything about meta tags: which ones matter, how to write titles and descripti... International SEO: How to Use hreflang Without Breaking Your Site Use hreflang without breaking your site: language vs country choices, the exact...
← All guides