Robots.txt for SEO and AI Crawlers: Rules, Examples and Mistakes

Robots.txt tells crawlers where they may go. It doesn't keep pages out of Google. Here are the rules Google follows, a split policy for AI crawlers and the mistakes that quietly cost traffic.

Pixel-art two-way signpost beside a server rack, a crawl rules file telling crawlers where they may go.

Robots.txt is a text file at the root of your site that tells crawlers which URLs they may fetch. It controls crawling, not indexing. Use it to keep bots out of low-value paths like internal search, carts and staging. Use noindex to keep pages out of results. And treat AI crawlers as separate lanes: training, search and user fetches.

That last part is new, and it's where most robots.txt files go wrong today. A team blocks "AI bots" in one line and quietly drops out of ChatGPT search. Or it blocks Google-Extended and thinks it opted out of AI Overviews. It didn't.

This post covers what the file does, the exact rules Google follows, a policy for AI crawlers, copy-ready examples and the mistakes I find in audits.

Key takeaways

  • Crawling, not indexing. A blocked URL can still be indexed if other sites link to it.
  • One group per bot. A crawler follows only its most specific group, so repeat your shared rules there.
  • AI crawlers come in lanes. Training bots and search bots are separate, so block them separately.
  • Google-Extended isn't Search. AI Overviews run on Googlebot, with their own control in Search Console.
  • Server errors stop crawling. A robots.txt that returns 5xx can pause Google's crawl of your whole site.

What does robots.txt actually do?

Robots.txt is a set of crawl rules for bots that choose to follow them. Google's introduction to robots.txt says it's used "mainly to avoid overloading your site with requests." The same page says it "is not a mechanism for keeping a web page out of Google."

Here's the trap. If you block a page, Google can't read it. So it can't see a noindex tag on that page either. If other sites link to the URL, it can still be indexed, and the result shows with no description. To remove a page from results, allow crawling and add noindex. Robots.txt and noindex work against each other on the same URL.

Goal Right tool Wrong tool
Keep bots out of internal search and filters Robots.txt disallow Noindex alone
Keep a page out of Google results Noindex tag, crawling allowed Robots.txt disallow
Pick one URL among duplicates Canonical tag or redirect Robots.txt or noindex
Hide private content Password or login Robots.txt (the file is public)
Stop training use by an AI company Robots.txt for that company's training bot Blocking every bot

For duplicates, the canonical tags guide covers the right setup. Compliance is voluntary. Well-known crawlers follow the file. Scrapers may not. And since anyone can read your robots.txt, never list secret paths in it.

Where does the file go, and how does Google read it?

Google's robots.txt specification is precise. These are the rules that matter.

Three stat tiles: Google reads 500 KiB of robots.txt, caches it up to 24 hours, and uses a cached copy for 30 days of 5xx errors.Three stat tiles: Google reads 500 KiB of robots.txt, caches it up to 24 hours, and uses a cached copy for 30 days of 5xx errors.
Limits from Google's robots.txt specification: size, cache time and how long a cached copy stands in during server errors. Source: How Google interprets the robots.txt specification.
  • Location. The file lives at the root of the host. A copy in a subfolder is not valid. Rules apply only to the host, protocol and port that serve the file. So each subdomain needs its own.
  • Size. Google reads up to 500 KiB. Anything after that is ignored.
  • Fields. Google supports four: user-agent, allow, disallow and sitemap. Crawl-delay is not supported.
  • Case. Field names aren't case-sensitive. Paths are. "/Blog" and "/blog" are different rules.
  • Wildcards. The * matches any run of characters. The $ marks the end of a URL.
  • Precedence. The most specific rule wins, judged by the longest path. If two rules tie, Google uses the least restrictive one.
  • Caching. Google generally caches the file for up to 24 hours.

What happens when robots.txt returns an error?

This is the rule most teams don't know. Per the same spec, a 4xx error (other than 429) means Google treats the site as having no restrictions. A 5xx error is worse. For the first 12 hours, Google stops crawling the site. For the next 30 days, it uses the last good copy it cached. So a broken robots.txt on a server that throws errors can freeze crawling of every page you have.

Why does a bot ignore my shared rules?

Each crawler obeys only one group: the most specific one that names it. Google's spec says specific groups and the global * group are not combined. So if you write a group for OAI-SearchBot with just "Allow: /", it ignores your * rules. It will crawl your internal search pages too. Repeat any shared disallows inside each named group.

How should you handle AI crawlers in robots.txt?

AI companies now run more than one bot. One collects training data. One builds a search index. One fetches a page when a user asks. Blocking all of them treats three different deals as one.

Comparison of training and search crawlers for OpenAI, Anthropic and Google, and what blocking each lane removes.Comparison of training and search crawlers for OpenAI, Anthropic and Google, and what blocking each lane removes.
Each AI company runs a training lane and a search lane. Blocking one doesn't have to mean blocking the other. Source: Overview of OpenAI Crawlers.

Here's how the main ones split, from each company's own docs.

Company Training Search index User-triggered fetch
OpenAI GPTBot OAI-SearchBot ChatGPT-User
Anthropic ClaudeBot Claude-SearchBot Claude-User
Google Google-Extended (a token, not a bot) Googlebot Not applicable

OpenAI's crawler overview says sites that opt out of OAI-SearchBot "will not be shown in ChatGPT search answers." It says changes take about 24 hours to apply. It also says ChatGPT-User acts for a user, so "robots.txt rules may not apply." Disallowing GPTBot signals that your content shouldn't be used for training.

Anthropic's crawler help page gives the same three-way split. Blocking Claude-SearchBot or Claude-User may reduce your visibility in Claude's search results. Blocking ClaudeBot signals that future content should be left out of training.

What does Google-Extended control?

Google's list of common crawlers says Google-Extended has no user agent of its own. Crawling happens with existing Google user agents, and the token is used "in a control capacity." Google's page on AI features and your website ties it to training and grounding in some Gemini products, not to Search.

So blocking Google-Extended does not remove you from AI Overviews. Those run on Googlebot, as part of Search. Search Console now has a separate control for that. Its help article on generative AI features says the control reached all sites by August 31, 2026. Excluding a site there means "You won't receive any traffic or impressions from these features." The AI Overviews guide covers that trade.

Robots.txt examples you can copy

Start from the one that fits, then adjust the paths.

A standard site that allows AI search

All crawlers skip internal search, cart and account pages. OpenAI's search bot gets the same rules and stays in ChatGPT search. OpenAI's training bot is opted out.

User-agent: *
Disallow: /search
Disallow: /cart
Disallow: /account

User-agent: OAI-SearchBot
Disallow: /search
Disallow: /cart
Disallow: /account

User-agent: GPTBot
Disallow: /

Sitemap: https://www.example.com/sitemap.xml

The OAI-SearchBot group repeats the shared disallows on purpose. Without them, that bot would ignore the * group and crawl everything.

Blocking parameter URLs with wildcards

Faceted filters and session IDs waste crawl. The last rule blocks PDFs in one folder only.

User-agent: *
Disallow: /*?sort=
Disallow: /*?sessionid=
Disallow: /downloads/*.pdf$

Wildcards help most on large stores and listing sites. If your site has fewer than a few thousand URLs, you probably don't have a crawl budget problem. The crawl budget guide covers when it matters.

What a staging site should use

User-agent: *
Disallow: /

Use this on staging only, and add a password too. Then make sure the deploy process can't carry it to production. That's the most expensive mistake on this list.

Worked example: the staging file that shipped

Say a SaaS site earns 30,000 organic clicks a month. A redesign goes live on a Friday with the staging robots.txt still in place: "Disallow: /" for every bot.

Funnel of what a shipped staging robots.txt cost: 6,000 clicks, then 90 signups, then 9 paying customers gone.Funnel of what a shipped staging robots.txt cost: 6,000 clicks, then 90 signups, then 9 paying customers gone.
Worked example with assumed rates: a five-minute fix, found three weeks late, costs a year of revenue from nine customers. Worked example from this guide.

Google caches robots.txt for up to 24 hours, then sees the new rule. Pages already indexed stay for a while, but Google can't recrawl them. New pages can't be read at all. Titles and snippets go stale. Over the next weeks, rankings slide as competitors keep updating.

Assume the team catches it 21 days later. Clicks dropped 40% in the last two weeks of that window, about 6,000 lost clicks. The fix takes five minutes. The recovery takes longer, because Google has to recrawl everything.

Common robots.txt mistakes

These are the ones I find most often in a technical SEO audit.

  • Blocking to deindex. Disallow plus noindex means Google never sees the noindex. Allow the crawl, keep the tag.
  • Blocking CSS and JavaScript. Google's intro warns against blocking files it needs to understand a page. Blocked scripts can make a page look broken to Googlebot.
  • One line for "AI bots." It removes you from AI search along with training. Split the lanes.
  • Named groups without shared rules. The bot ignores your * group. Repeat the disallows.
  • Wrong case. "Disallow: /Admin" doesn't block "/admin".
  • Missing sitemap line. Add your XML sitemap URL. The XML sitemap guide covers what goes in it.
  • Blocking images you want found. Disallowing your image folder keeps images out of Google Images. The image SEO guide covers that side.

Platform defaults matter too. Shopify and Next.js each generate the file their own way. See the Shopify technical SEO guide and the Next.js SEO guide for the specifics.

How do you test robots.txt before it ships?

Test every change. A typo can block a whole folder.

  1. Read it in the browser. Open yourdomain.com/robots.txt. Check that it loads with a 200 status.
  2. Check the Search Console report. The robots.txt report shows the version Google fetched, when, and any parse errors. You can request a recrawl there after a critical fix.
  3. Test key URLs. Run your top pages through the URL Inspection tool and confirm they're allowed.
  4. Add a deploy check. Fail the build if production robots.txt contains "Disallow: /" on its own line.
  5. Watch AI visibility after changes. If you change AI bot rules, track citations for a few weeks. The guide to tracking AI search visibility shows how.

If you want a clean starting file, the free robots.txt generator has switches for each AI crawler. Some teams pair robots.txt with an llms.txt file. Google's docs say Google Search ignores those files, but other tools may read them. The llms.txt guide covers when it's worth the effort.

What to do this week

Robots.txt is one piece of technical SEO. It decides what can be crawled, which decides what can reach indexing. If you want AI answers to cite you, crawl access is step one. The guide on how to get cited in AI answers covers the rest, and the Perplexity SEO guide covers one engine in depth. For a full review of crawl access across Google and AI engines, see our AI search visibility work or the SEO and AEO service.

FAQ

Does robots.txt stop a page from being indexed?

No. Robots.txt controls crawling, not indexing. Google says a disallowed page can still be indexed if other sites link to it, and it may show in results with no description. To keep a page out of search, allow crawling and add a noindex tag, or put the page behind a password.

Should I block GPTBot?

It depends on what you want. GPTBot collects content that may be used to train OpenAI's models. Blocking it opts you out of training. It does not remove you from ChatGPT search, which uses a separate crawler called OAI-SearchBot. Most businesses that want AI visibility allow OAI-SearchBot and decide on GPTBot as a separate policy choice.

Does blocking Google-Extended remove my site from AI Overviews?

No. Google-Extended is a robots.txt token that controls use of your content for training and grounding in some Gemini products. It doesn't control Google Search. AI Overviews and AI Mode are part of Search, and Search Console now has a separate control to include or exclude a site from those generative AI features.

Where does the robots.txt file go?

It must sit at the root of the host, like example.com/robots.txt. A file in a subfolder is ignored. Each subdomain, protocol and port needs its own file, so blog.example.com and shop.example.com each need one. Google reads up to 500 KiB of the file and ignores anything after that.

How long does Google take to see robots.txt changes?

Google generally caches robots.txt for up to 24 hours, so changes usually take effect within a day. It can cache longer if the file can't be fetched. OpenAI says its search systems take about 24 hours to adjust after a robots.txt update. You can ask Google to recrawl the file faster from the robots.txt report in Search Console.

Does Google follow crawl-delay?

No. Google supports only four fields in robots.txt: user-agent, allow, disallow and sitemap. Crawl-delay is ignored by Googlebot. Some other crawlers may read it, but don't count on it. If Googlebot is putting real load on your server, fix the server side or use the crawl rate options Google documents instead.

More like this

Glossary: AI Crawlers

Startup? Let's talk.

20 minute fit call. You'll leave knowing the first thing we'd fix and roughly what it costs. If we're not the right fit, we'll tell you who is.