What Is Robots.txt: Rules, Examples and How to Manage AI Crawlers

What robots.txt controls and what it cannot, how Google reads its rules, errors and limits, and how to allow or block OpenAI, Anthropic and Google AI crawlers.

An abstract low-angle view of a curved building facade clad in a pale diamond-pattern lattice, sweeping upward against a soft grey sky.
Photo: Victor via Unsplash

Key Takeaways

A robots.txt file is a plain text file at the root of a site that tells crawlers which URLs they may request. It manages crawling, not indexing, and it is now the main way to opt in or out of AI crawlers.

  • Robots.txt controls crawling, but blocked URLs can still be indexed.
  • Each host and protocol needs its own robots.txt file.
  • Google ignores content beyond the first 500 KiB.
  • Google usually caches the file for up to 24 hours.
  • GPTBot, ClaudeBot and Google-Extended each have their own token.

What a robots.txt file is

A crawl control, not an index control

Google's robots.txt introduction says the file is used mainly to avoid overloading a site with requests. It is not a way to keep a page out of Google, which needs noindex or password protection.

The file is also a marketing decision now. Which AI tools may read your pages shapes your AI search visibility, so growth teams should know what it says.

Where the file lives

The file must be named robots.txt and sit at the root of the host it applies to, such as https://www.example.com/robots.txt. A file placed in a subfolder is not valid.

A robots.txt file can also sit on a subdomain or on a non-standard port, such as example.com:8181/robots.txt. In each case it controls only that exact location.

One file per host and protocol

Rules apply only to the protocol, host and port where the file is posted. A file on https://example.com does not cover m.example.com or http://example.com.

The format follows the Robots Exclusion Protocol, published by the IETF as RFC 9309 in September 2022.

How robots.txt rules work

User-agent groups

A file contains one or more groups, and each group starts with a user-agent line naming the crawler it targets. An asterisk targets all crawlers, though Google says its AdsBot crawlers must be named explicitly.

A crawler obeys only the first, most specific group that matches it. Groups for the same user agent are combined before processing.

The four supported fields

Google's guide to writing the file lists the fields its crawlers support:

  • User-agent: the crawler a group applies to.
  • Disallow: a path the crawler should not request.
  • Allow: a path that overrides a broader disallow rule.
  • Sitemap: the full URL of a sitemap file.

Paths must start with a slash, and lines that match no rule are ignored.

Wildcards and case

Rules are case-sensitive, so a rule for /file.asp does not block /FILE.asp. Google supports two wildcards: an asterisk for any sequence of characters and a dollar sign for the end of a URL.

Which rule wins

Google picks the most specific rule, measured by the length of the rule path. When an allow rule and a disallow rule conflict, Google uses the least restrictive rule.

How Google handles errors and limits

Status codes

Google's robots.txt specification treats server responses in different ways:

  • 3xx: Google follows at least five redirect hops, then treats the file as a 404.
  • 4xx except 429: Google assumes there are no crawl restrictions.
  • 5xx: Google uses the last good copy for 30 days while it retries.

A missing file is therefore harmless, but a broken server can freeze old rules for a month.

Caching and size

Google generally caches the file for up to 24 hours, longer if it cannot refresh it. It enforces a 500 KiB size limit and ignores any content beyond it.

Unsupported fields

Google does not support crawl-delay or other fields outside its list. Other crawlers may read them, so check each bot's own documentation.

What robots.txt cannot do

Blocked pages can still appear in search

Google says a disallowed URL can still be indexed if other pages link to it. The result may then show the URL and anchor text but no description.

Noindex needs crawl access

Google's noindex guide says the rule must be in a meta tag or HTTP header, not in robots.txt. If robots.txt blocks the page, Googlebot never sees the noindex tag.

It is not a security tool

The file cannot enforce anything, and only well-behaved crawlers obey it. Private files need password protection on the server.

How to manage AI crawlers

OpenAI's three agents

OpenAI's crawler documentation separates search from training. OAI-SearchBot surfaces sites in ChatGPT search, while GPTBot collects content that may be used to train its foundation models.

Each setting is independent, so you can allow OAI-SearchBot and block GPTBot. ChatGPT-User acts on user requests, and OpenAI says robots.txt rules may not apply to it.

Sellers who want product pages found in ChatGPT should keep OAI-SearchBot allowed, as our guide to selling on ChatGPT covers.

Anthropic's bots

Anthropic's crawler page lists ClaudeBot for training, Claude-SearchBot for search quality and Claude-User for user-directed requests. Anthropic says blocking Claude-SearchBot or Claude-User may reduce a site's visibility in user search results.

Anthropic also supports the non-standard crawl-delay field. It asks site owners to add rules on every subdomain they want to opt out.

Google-Extended

Google-Extended is a token, not a separate crawler, that controls whether Google uses your content to train its generative AI foundation models. It also covers grounding in Google AI products outside Search, and Google says it does not affect inclusion or ranking in Google Search.

A new training signal

Anthropic began recognising a shared "no AI training" preference signal on 30 October 2026, based on draft work in the IETF aipref working group. Google's crawler list says it intends to support a shared training preference signal, written as user-agent: __usage_ai-training, in early 2027.

How to write and test the file

Create it as plain text

Write the file in a plain text editor and save it as UTF-8. Google warns that word processors can add curly quotes and other characters that break rules.

Google describes four steps: create the file, add rules, upload it to the site root and test it. Once the file is live, Google's crawlers find and use it automatically, with no submission needed.

Use your platform's settings first

Google notes that hosted platforms such as Wix or Blogger may offer a search settings page instead of direct file access. If you are still choosing a platform, our website builder ranking compares the main options.

Test it in Search Console

Open the file in a private browser window to confirm it is public. Then use the robots.txt report in Search Console, which shows files for the top 20 hosts and lets you request a recrawl after urgent fixes.

Common mistakes to avoid

Blocking resources Google needs

Blocking scripts or style files can stop Google from understanding a page. Only block resources if pages still make sense without them.

Blocking the bots that send traffic

A blanket disallow for every AI agent can also keep you out of AI search, since OpenAI says sites that block OAI-SearchBot will not be shown in ChatGPT search answers. Decide bot by bot, and treat training bots and search bots separately.

Forgetting subdomains

Every subdomain needs its own file, because rules are never inherited. Audit shop, blog and help subdomains as well as the main site.

Conclusion

Robots.txt is a short text file that decides which crawlers may request which URLs, and Google reads it under strict rules on size, caching and errors. Use it to manage crawl load and AI bots one by one, and use noindex or passwords when a page must stay out of search.

Frequently Asked Questions

Where should a robots.txt file be placed?

A robots.txt file must sit at the root of the host it controls, such as example.com/robots.txt, and each subdomain or protocol needs its own file.

Does robots.txt stop a page from being indexed?

Robots.txt does not reliably stop indexing, because Google can still index a blocked URL that other pages link to, so use noindex or a password instead.

Does Google support crawl-delay?

Google does not support the crawl-delay field, although some other crawlers, including Anthropic's bots, say they respect it.

How do I block GPTBot?

To block GPTBot, add a group with user-agent: GPTBot and disallow: / to robots.txt, which signals that OpenAI should not use the content for training.

Does blocking Google-Extended hurt my rankings?

Blocking Google-Extended does not affect inclusion or ranking in Google Search, according to Google, and only limits training of its generative AI models and grounding outside Search.

How large can a robots.txt file be?

Google enforces a 500 KiB limit on robots.txt files and ignores any rules that appear after that point in the file.

How quickly does Google see robots.txt changes?

Google generally caches robots.txt for up to 24 hours, and the Search Console robots.txt report lets you request a faster recrawl after urgent fixes.

Sources: Google Search Central robots.txt documentation, Google crawler and Google-Extended pages, RFC 9309, OpenAI crawler documentation and Anthropic's crawler help page, all linked above. Figures checked 29 November 2026. This is not legal advice.