Audit my site
Technical SEOIntermediateChecked against Google docs · Oct 2026

robots.txt and AI crawlers: syntax, matching rules and what to block

robots.txt tells crawlers which URLs they may fetch. It controls crawling, not indexing, and it is now also where you decide which AI crawlers may use your content.

Author: Eugene Serbin, Head of SEO at Semalt Updated: 29 October 2026 Reading time: 13 min Visuals: 5

In short

robots.txt is a plain text file at the root of your site that tells crawlers which URLs they may fetch. It controls crawling, not indexing, so a blocked URL can still appear in Google, just without a snippet. The same file is also how you tell AI crawlers such as GPTBot or the Google-Extended token whether your content may be used for model training or AI search answers.

What robots.txt does and does not do

A Disallow rule tells a crawler “do not fetch this URL”. It does not tell Google “do not show this URL in search”. Those are two different instructions, and mixing them up is the root of most robots.txt problems.

If a page is blocked, Google cannot read its content. But if other pages link to it, Google can still index the bare URL and show it in results without a description. To keep a page out of search, you need noindex in a robots meta tag or an X-Robots-Tag HTTP header, and the page must stay crawlable so Google can see that rule.

robots.txt is also voluntary. Well-behaved crawlers follow it, but it is not access control: anyone, and any bot that ignores the file, can still open a blocked URL. Private content needs a password or other authentication.

Diagram · Crawling vs indexing
robots.txt controls crawling, noindex controls indexing Top row: a page blocked with Disallow is not fetched, so its noindex is never seen and the URL may still be indexed without a snippet. Bottom row: a crawlable page with noindex is fetched, Google reads the noindex and the page is dropped from search results. BLOCKED IN ROBOTS.TXT CRAWLABLE, WITH NOINDEX robots.txt rule Disallow: /old/ Googlebot does not fetch the page A noindex on the page is never seen URL may still be indexed, no snippet Page stays crawlable and has noindex Googlebot fetches the page Google reads the noindex rule Page is dropped from search results
Blocking a URL hides its content from Google, not the URL itself. Only a noindex that Google can read removes a page from search.

What Google officially says

“Google can't index the content of pages which are disallowed for crawling, but it may still index the URL”

Google Search Central — robots.txt documentation. Such URLs are shown without a snippet.

“Google supports the following fields (other fields such as crawl-delay aren't supported)”

Google Search Central — robots.txt documentation. The supported fields are user-agent, allow, disallow and sitemap.

A few more rules from the same documentation, each a direct quote:

The robots meta tag documentation adds the point that matters most in practice: if robots.txt blocks a page, Google cannot see the noindex on it, so that noindex is ignored.

Where the file lives

The file must sit at the root of the host and be called exactly robots.txt: https://example.com/robots.txt. A file at https://example.com/pages/robots.txt is not read.

Its scope is narrow. Because rules apply only to the host, protocol and port where the file is served:

The file must be “a UTF-8 encoded plain text file”, and Google reads only the first 500 KiB. If yours is close to that size, it is almost always full of rules you can replace with a few wildcards.

Syntax: user-agent, disallow, allow, sitemap

A robots.txt file is a list of groups. Each group starts with one or more User-agent lines and is followed by the Disallow and Allow rules for those crawlers. Sitemap lines stand on their own and do not belong to any group.

Code · Anatomy of a robots.txt file
# Rules for every crawler without a group of its own
User-agent: * 1
Disallow: /search 2
Allow: /search/help 3
Disallow: /*?sort=
Disallow: /cart/

# OpenAI's training crawler: a separate group
User-agent: GPTBot 4
Disallow: /

Sitemap: https://example.com/sitemap.xml 5
  • 1Group start. * matches any crawler that has no more specific group in the file.
  • 2Disallow. The path starts with / and is case-sensitive. /search also blocks /search?q=shoes and /search-tips.
  • 3Allow. A longer, more specific path wins, so the help page stays crawlable while the rest of /search is blocked.
  • 4A crawler-specific group. GPTBot follows only this group and ignores the * group entirely.
  • 5Sitemap. A full URL, outside any group. You can list several sitemaps.
Lines starting with # are comments. Each crawler picks one group, then applies the rules inside it.

Fields Google understands

Everything else is ignored by Google. Crawl-delay is the common example: some other search engines read it, Google does not. A Noindex: line in robots.txt does nothing either.

Groups for several crawlers

Google's documentation says: “You can group together rules that apply to multiple user agents by repeating user-agent lines for each crawler.” So this is one valid group that applies to both crawlers:

User-agent: GPTBot
User-agent: CCBot
Disallow: /

The key rule to remember: a crawler obeys only the most specific group that matches its name. If you add a User-agent: Googlebot group, Googlebot stops reading the * group, so any rule you still want for Googlebot must be repeated inside its own group.

Wildcards and matching rules

Rules match the start of the URL path, and Google supports two special characters:

Google also states that “The path value must start with / to designate the root and the value is case-sensitive.” /Admin/ and /admin/ are different paths.

When several rules in a group match the same URL, Google uses “the most specific rule based on the length of the rule path”. If rules conflict, “Google uses the least restrictive rule.” In practice: the longer path wins, and when two matching rules are equally specific, Allow beats Disallow.

Diagram · How Google picks the rule for a URL
Choosing the rule that applies to /search/help/faq For the path /search/help/faq, Disallow: /search matches with 7 characters, Allow: /search/help matches with 12 characters, and Disallow: /*?sort= does not match. Google keeps the longest matching rule, so crawling is allowed. URL path being checked /search/help/faq RULES IN THE GROUP HOW GOOGLE DECIDES Disallow: /search Allow: /search/help Disallow: /*?sort= matches · 7 chars matches · 12 chars no match 123 Collect the rules that match Keep the longest rule path Same length? Least restrictive wins Crawling allowed Allow: /search/help (12 characters) is more specific than Disallow: /search (7 characters).
Order in the file does not matter to Google: the longest matching path decides, and Allow wins a tie.

Worked examples:

RuleBlocksDoes not block
Disallow: /blog/blog, /blog/, /blog-news, /blog.html/Blog, /news/blog
Disallow: /blog/Everything inside the folder: /blog/post-1/blog, /blog-news
Disallow: /*.pdf$URLs that end in .pdf: /files/guide.pdf/files/guide.pdf?v=2
Disallow: /*?sort=/shoes/?sort=price/shoes/, /shoes/?page=2
Disallow: (empty)NothingEverything is allowed

A missing file has the same effect as an empty rule: if /robots.txt returns 404, everything is allowed.

What to block and what never to block

Block URLs that waste crawling on pages nobody needs in search. Leave alone everything Google needs to render and understand the pages you want to rank.

Checklist · Block vs never block

✓ Good candidates to block

  • Internal search results: /search
  • Endless filter and sort combinations: /*?sort=
  • Cart and checkout
  • URLs with session IDs
  • Admin areas (behind a login anyway)

✕ Never block

  • CSS, JavaScript and images needed to render the page
  • Pages you want removed with noindex
  • The whole site on production: Disallow: /
  • Pages you want indexed and listed in your sitemap
The left column saves crawling; every item in the right column can cost you rankings or leave pages stuck in the index.

A whole-site Disallow: / usually arrives by accident: it protects a staging site and is copied to production at launch. Check the live file every time a new version of the site goes out.

robots.txt vs noindex

The two tools answer different questions. robots.txt answers “may you fetch this URL?”. noindex answers “may you show this page in search?”.

Combining them on the same URL does not work. A blocked page is never fetched, so Google never sees its noindex, ignores it, and may keep the URL in the index without a snippet. If you want a page out of search, let Google crawl it with noindex in place.

GoalUse
Stop crawling of low-value URLs, such as internal search or sort parametersrobots.txt Disallow
Remove a page from search resultsnoindex (meta tag or X-Robots-Tag), page left crawlable
Consolidate duplicates on one URL301 redirect or rel="canonical", not robots.txt
Keep content privatePassword or other authentication

AI crawlers: who is who

AI companies publish their own user-agent tokens, and you address them in robots.txt exactly like Googlebot. The important detail is that one company often runs several bots with different jobs: blocking a training crawler is not the same as leaving an AI search product.

Table · AI crawler tokens and what blocking them changes
TokenCompanyPurposeEffect of blocking
GooglebotGoogleCrawls for Google Search, including AI Overviews and AI ModePages drop out of Google Search. Do not block it.
Google-ExtendedGoogleControls whether content is used for Gemini modelsNo effect on Search, ranking, AI Overviews or AI Mode
GPTBotOpenAICollects content for model trainingOpts your content out of OpenAI training
OAI-SearchBotOpenAIFinds pages for ChatGPT search resultsCan remove you from ChatGPT search answers
ChatGPT-UserOpenAIFetches a page when a user asks ChatGPT toAffects user-requested visits; check OpenAI's docs for how robots.txt applies
ClaudeBotAnthropicAnthropic's web crawlerClaudeBot stops crawling your site
PerplexityBotPerplexityIndexes pages for Perplexity's answersCan remove you from Perplexity answers
CCBotCommon CrawlBuilds open web datasets, widely used for AI trainingPages are left out of future Common Crawl crawls
Tokens and their purposes change over time, so check each provider's current documentation before you edit your file.

Check the providers' pages before you copy rules. AI companies add, rename and redefine crawler tokens. Each provider documents its current tokens, and only its own page tells you what blocking one actually changes. Blocking also works only from now on: it does not remove content a crawler has already collected.

Google: Googlebot and Google-Extended

Googlebot crawls for Google Search. Google-Extended is a robots.txt token that controls whether your content is used for Google's Gemini models. Google states that it does not affect inclusion or ranking in Google Search.

AI Overviews and AI Mode are part of Search and use Googlebot, so blocking Google-Extended does not remove your site from them. The only way out of those features via robots.txt would be to block Googlebot, which removes you from Search as a whole.

# Keep content out of Gemini models, stay in Google Search
User-agent: Google-Extended
Disallow: /

OpenAI: GPTBot, OAI-SearchBot, ChatGPT-User

OpenAI separates its bots by job. GPTBot is for model training, OAI-SearchBot for ChatGPT search results, and ChatGPT-User fetches pages when a user asks ChatGPT to open them. Blocking OAI-SearchBot can remove you from ChatGPT search answers, so most sites that want to opt out of training block only GPTBot:

# Opt out of training, stay visible in ChatGPT search
User-agent: GPTBot
Disallow: /

User-agent: OAI-SearchBot
Allow: /

Anthropic: ClaudeBot

Anthropic's crawler uses the token ClaudeBot. Check Anthropic's documentation for what it collects and whether other Anthropic agents use separate tokens.

User-agent: ClaudeBot
Disallow: /

Perplexity: PerplexityBot

PerplexityBot indexes pages for Perplexity's answer engine. Blocking it can remove your pages from Perplexity answers, which is a traffic source for some sites, so decide deliberately.

Common Crawl: CCBot

CCBot builds Common Crawl's open web datasets, which are widely used for AI training. Blocking it keeps your pages out of future crawls. It cannot take them out of datasets that were already published.

How errors in robots.txt affect crawling

What Google does depends on the HTTP status code the file returns:

Response for /robots.txtWhat Google does
200 with valid contentApplies the rules.
4xx, such as 403 or 404 (except 429)Google treats “all 4xx errors, except 429, as if a valid robots.txt file didn't exist”. There are no crawl restrictions.
5xx and 429For the first 12 hours Google stops crawling the site but keeps trying to fetch robots.txt. After that, if it still cannot get a new version, it uses the last good version for up to 30 days. After 30 days, handling depends on whether the rest of the site is generally available.

Two practical consequences. A server error on robots.txt can stop crawling of your whole site, so monitor it like any important page. And a 403 on robots.txt, often caused by a firewall or bot protection, does not block anything: Google reads it as “no rules”.

Because Google generally caches the file for up to 24 hours, a fix may take up to a day to be picked up.

Testing and monitoring

  1. Open the file in a browser at https://example.com/robots.txt and check that it returns 200 and the content you expect, on every host and subdomain.
  2. Check the robots.txt report in Search Console. It shows the versions Google fetched, when, and any errors or warnings it found.
  3. Test key URLs with URL Inspection. It shows whether a URL is blocked by robots.txt. Test your main templates: home, category, product, article.
  4. Watch the Page indexing report. The status Indexed, though blocked by robots.txt lists URLs Google indexed without crawling them. If you want them in search, unblock them. If you want them gone, unblock them and add noindex.
  5. Compare robots.txt with your sitemap. A sitemap should not list URLs that robots.txt blocks. That is a contradictory signal.

Check your robots.txt

The OurSEO Tools checklist checks your robots.txt and flags URLs that your sitemap lists but robots.txt blocks, so you can spot conflicting signals in one run.

69-point checklistTechnical crawlContent analysis

Common mistakes

FAQ

Can I use robots.txt to remove a page from Google?

No. robots.txt blocks crawling, not indexing, and a blocked URL can still be indexed without a snippet. Leave the page crawlable and add noindex.

Does blocking an AI crawler remove my site from AI answers?

It depends on the token. Blocking GPTBot opts you out of OpenAI training, while blocking OAI-SearchBot can remove you from ChatGPT search. Blocking Google-Extended keeps content out of Gemini models but does not affect Google Search, AI Overviews or AI Mode. Check each provider's current documentation, as tokens change.

How long until Google sees my changes?

Google generally caches robots.txt for up to 24 hours, so allow up to a day. The robots.txt report in Search Console shows when Google last fetched the file.

What happens if robots.txt returns 404?

Google treats it as if there were no file, so everything may be crawled. A 5xx error is different: Google pauses crawling of the site at first.

Can I use wildcards?

Yes. Google supports * for any sequence of characters and $ for the end of the URL. Disallow: /*.pdf$ blocks URLs that end in .pdf.

Do all bots obey robots.txt?

No. Following it is voluntary. Major search engines and well-behaved bots respect it, but it is not access control. Protect private content with authentication.

Sources

Quotes checked against the official pages on 29 October 2026.