What is robots.txt? Definition, syntax and examples

Robots.txt is a plain text file in the root of a host that tells search engine crawlers which URLs they may and may not request. Martijn Koster proposed the Robots Exclusion Protocol in 1994, and the IETF published it as the official standard RFC 9309 in September 2022, co-authored by three Google engineers. Google reads up to 500 KiB of the file and usually caches it for up to 24 hours.

Updated: 17 October 20263 min read
Infographic: how a crawler reads robots.txt, fetch, match user-agent, apply rules, read sitemap, cache
Source: Google Search Central; RFC 9309

How does robots.txt work?

Robots.txt works as a set of crawl rules that a well-behaved crawler downloads and reads before it requests any other URL on the host. Google describes its main purpose as preventing your server from being overloaded with requests. Compliance is voluntary: Googlebot, Bingbot and other reputable crawlers follow it, but scrapers may not, so it is not a security tool.

Robots.txt controls crawling, not indexing. A blocked URL can still appear in Google if other pages link to it, usually without a description. To keep a page out of the index, use noindex and let Google crawl the page so it can see the tag.

Robots.txt syntax and rules

A robots.txt file consists of groups that start with a user-agent line followed by allow and disallow rules. Google supports 4 fields: user-agent, allow, disallow and sitemap. A simple example as plain text:

  • User-agent: *
  • Disallow: /cart/
  • Disallow: /*?sort=
  • Allow: /cart/help/
  • Sitemap: https://example.com/sitemap.xml

The layers below summarize how Google interprets the file.

Location and scope

The file must sit at the root of the host, for example https://example.com/robots.txt. It applies only to that exact protocol, host and port, so shop.example.com and example.com need separate files.

Wildcards and precedence

The asterisk matches any sequence of characters and the dollar sign marks the end of a URL. Paths are case-sensitive. When rules conflict, Google applies the most specific rule (the longest matching path), and on a tie the least restrictive one wins.

HTTP status codes

A 4xx response (except 429) means no restrictions at all. A 5xx response makes Google pause crawling for 12 hours, then use the last cached copy for up to 30 days. Google follows up to 5 redirect hops to reach the file.

Unsupported rules

Google ignores crawl-delay, nofollow and noindex in robots.txt. It stopped honoring noindex there on 1 September 2019, noting that such rules were contradicted by other rules in all but 0.001% of files. Bing, by contrast, supports crawl-delay as a relative throttle value.

Robots.txt in SEO and AI search

In SEO, robots.txt is a tool for spending crawl budget on pages that matter: blocking internal search results, endless filter combinations and cart pages on large e-commerce sites. It should never block CSS or JavaScript that Google needs to render the page, because that changes how Google understands the content.

Robots.txt is also where you control AI crawlers. Google offers the Google-Extended token, which decides whether Google may use your content to train Gemini models and to ground answers in Gemini Apps and Vertex AI. Google states that it does not affect inclusion or ranking in Google Search. Other AI crawlers identify themselves with their own user-agent names, so you can allow or block each one in a separate group.

GoalUse robots.txt?Better tool
Reduce crawling of filter URLsYesDisallow pattern
Remove a page from GoogleNonoindex or 404/410
Hide private contentNoPassword protection
Consolidate duplicatesNoCanonical tag

Robots.txt on multilingual and multi-country sites

On international sites, robots.txt mistakes can silently remove an entire market from Google. Each ccTLD and each subdomain (de.example.com, cz.example.com) needs its own file, and the rules should match across versions. Google’s guidance on locale-adaptive pages says robots rules should be identical for all locales. Blocking /en/ during a staging phase and forgetting to remove the rule is a mistake I have seen more than once after a language launch.

Blocking hreflang alternates is equally harmful. If Google cannot crawl the German version, it cannot confirm the return link in your hreflang set, and the annotations for that pair are lost. Check robots.txt for every host in the Search Console robots.txt report after each deployment.

Pro tip: Keep robots.txt in version control with your code and add an automated check that fails the deployment when it contains “Disallow: /” for all user-agents on production. It is a 5-minute safeguard against the most expensive one-line mistake in SEO.

Robots.txt review is part of every technical SEO project I run, and of my international SEO audits for sites with several domains. Pair it with a clean XML sitemap.

Frequently asked questions about Robots.txt

Does robots.txt stop a page from being indexed?

No. Robots.txt blocks crawling, but a blocked URL can still be indexed if other pages link to it. Use a noindex tag and allow crawling to keep a page out of Google.

Where should robots.txt be placed?

Place it in the root directory of each host, for example https://example.com/robots.txt. Every subdomain and every protocol needs its own file.

Does Google support crawl-delay?

No, Google ignores crawl-delay. Bing supports it as a relative throttle value, while Google adjusts its crawl rate automatically based on server responses.

Can robots.txt block AI crawlers?

Yes, for crawlers that respect it. Google-Extended controls the use of content for Gemini models, and other AI crawlers can be targeted by their own user-agent names.

Related terms

International SEO · AI SEO (GEO)

Grow in every market, and get cited by AI

One wrong line in robots.txt can hide a whole country version from Google and from AI search. I review robots.txt, crawl rules and AI crawler access for every domain and subdomain of multi-market sites.

I help SaaS and e-commerce brands win organic traffic across Europe and the US, and get their brand recommended in ChatGPT, Gemini, Perplexity and Google AI Overviews. Every project starts with a free audit of your site, your markets and your visibility in AI answers.

Write to Adrian

Have a question about this term or your SEO?

Send a short message about your website, the markets you sell in and what you want to achieve. You get a reply from me, not from a sales team.

  • Free preliminary SEO and AI visibility audit
  • Strategy for international and multilingual markets
  • Reply within one business day
Book a free call
Adrian Dąbrowiecki

Write to Adrian

Adrian Dąbrowiecki · Marketer Coffee

Tell me about your site and your goals. I usually reply within one business day.