Robots.txt
Robots.txt communicates crawling preferences to search and AI crawlers. Learn how rules work, how they differ from noindex and access control, and how to test a policy.
Robots.txt is a public text file through which a website communicates its crawling preferences to automated clients. It belongs to the Robots Exclusion Protocol (REP), introduced in 1994 and standardized in 2022 as RFC 9309. A crawler normally consults the file before fetching documents from an origin. The file can specify which URL paths particular crawlers may or may not request.
For technical SEO, robots.txt is principally a mechanism for managing crawling, not a catalogue of pages that should appear in search results. For publishers concerned with generative AI, it can also communicate preferences to certain AI services. Neither function should be confused with a security boundary: the file is publicly readable, and a client that ignores the protocol can attempt to request any publicly accessible URL.
Where robots.txt lives and how it works
The conventional address is the root of the origin, for example https://example.com/robots.txt. A file stored at /blog/robots.txt does not establish an independent policy for that directory. The scheme, hostname and port matter: the rules for an HTTPS website are not automatically the rules for its HTTP counterpart or a separate subdomain. A multilingual website using language directories, on the other hand, normally uses the same root file for all languages.
Serve a plain UTF-8 text document with an appropriate content type rather than an HTML page generated by the CMS. A small file that is consistently available is preferable to a complex file generated from changing application state. A simple policy might look like this:
User-agent: *
Disallow: /search/
Disallow: /preview/
Sitemap: https://example.com/sitemap.xml
This example asks compliant crawlers not to request two sets of URLs. It also advertises the location of the sitemap, an extension recognized by major search engines. It does not require a crawler to fetch every URL in the sitemap, nor does a sitemap override a disallow rule. Other public paths remain available unless an applicable rule restricts them. The example assumes that internal search and preview URLs have no independent search value; this assumption must be checked on a real website.
Directives, groups and URL matching
A user-agent group identifies a crawler by its product token. Multiple user-agent lines may share a set of rules. A crawler looks for applicable specific groups and uses the wildcard group when no specific group matches. Separate groups for the same matching token are combined under the standardized matching model. A rule from the wildcard group should not be assumed to be inherited by a more specific group: repeat any necessary restrictions in that group.
| Directive or syntax | Purpose | Important qualification |
|---|---|---|
User-agent: | Identifies the intended crawler | A product token, not necessarily the complete HTTP User-Agent header |
Disallow: | Requests that matching paths not be crawled | An empty value imposes no path restriction |
Allow: | Permits matching paths, including exceptions | Specificity determines which overlapping rule applies |
* / $ | Wildcard and end-of-match marker | Not a general regular expression language |
Sitemap: | Advertises an absolute sitemap URL | Extension, not a crawl permission |
Crawl-delay: | Requests a delay from supporting crawlers | Not standardized by REP; Google does not support it |
Path matching is sensitive to distinctions such as case and the trailing slash. Where both an Allow and a Disallow match a URL, the more specific match wins; in an equivalent match, Allow is preferred under the RFC recommendation. Percent-encoded characters and non-ASCII paths require attention to the standard's encoding rules. Test real URLs rather than relying on visual similarity between strings.
User-agent: *
Disallow: /catalog/
Allow: /catalog/public/
Disallow: /*?*sort=
In this illustrative policy, /catalog/item/ is restricted but /catalog/public/item/ is permitted by the longer exception. A query containing a sort parameter may match the final rule, depending on its exact spelling. Before adopting a pattern like this, determine whether sorting, filters or pagination produce valuable landing pages; a broad restriction can unintentionally hide legitimate products or articles from crawlers. Google documents its interpretation in the robots.txt specification guide.
Crawling, indexing and confidentiality are different problems
Suppose an article has already been linked from another website. Even if a crawler is instructed not to retrieve the article, it may know that the address exists. The search engine can therefore retain or display a URL without having access to the text that would normally support a descriptive result. A robots.txt block should not be treated as a reliable way of removing an HTML page from a search index.
| Objective | Appropriate mechanism | What to avoid |
|---|---|---|
| Reduce crawling of low-value URL patterns | Targeted robots.txt rules and better URL architecture | Blocking valuable content or rendering assets |
| Keep an accessible HTML page out of search | Robots meta noindex, with crawling permitted | Blocking access before the crawler sees the directive |
| Exclude a public PDF from supporting search indexes | X-Robots-Tag: noindex in the HTTP response | Adding an HTML meta element to a non-HTML resource |
| Protect private or confidential data | Authentication and server-side authorization | Publishing sensitive paths as if Disallow were a password |
| Consolidate duplicate pages | Consistent canonical signals or relevant permanent redirects | Using a crawl block as a canonical declaration |
Google explains the crucial dependency in its noindex documentation: the crawler must be able to retrieve the directive. In an HTML document the directive belongs in the head; for a resource such as a PDF it can be sent in the HTTP response. A page already indexed may need to be recrawled before removal takes effect. For duplicate pages, consider the canonical URL or an HTTP 301 redirect when the address has actually moved.
<meta name="robots" content="noindex, follow">
X-Robots-Tag: noindex
These are two different places to express an indexing preference, not two lines to copy into robots.txt. A public test environment can use a crawlable noindex response during editorial preparation, but genuinely unreleased content requires access control. Removing a noindex directive later makes a document eligible for reconsideration; it does not guarantee immediate indexing.
Robots.txt and generative AI crawlers
The phrase AI crawler hides several different functions. A service may collect documents for future training, maintain a search index, or retrieve a page in response to an individual request. A publisher who wants readers to discover its articles in AI search may have a different preference about model training. Treat these decisions separately, and verify that the specific service offers a corresponding control.
| Product token or control | Primary purpose | Publisher consideration |
|---|---|---|
| Googlebot | Google Search crawling | Restrictions can affect ordinary search and discovery for AI search |
| Google-Extended | Usage control for certain Google generative AI products | Not a separate crawler identity in access logs; not a Search ranking control |
| Search generative AI control | Google Search and Discover generative grounding | Configured in Search Console, not a robots.txt group |
| OAI-SearchBot | Discovery for ChatGPT search | Allow when seeking inclusion in that experience |
| GPTBot | Potential training-data collection | Can be restricted independently of OAI-SearchBot |
| ChatGPT-User | User-initiated retrieval | Robots.txt rules may not apply to every user-initiated request |
The OpenAI crawler documentation distinguishes these three OpenAI tokens. The example below expresses one possible policy: permit search discovery while restricting GPTBot. It repeats the general search-path restriction explicitly. It is not a universal policy recommendation, and permission cannot guarantee citations or referral traffic.
User-agent: *
Disallow: /search/
User-agent: OAI-SearchBot
Disallow: /search/
User-agent: GPTBot
Disallow: /
Google's generative AI controls guide, updated in November 2026, describes a separate Search Console setting for grounding in Search and Discover generative experiences. Publishers can use that setting independently of Google-Extended, which concerns certain other generative uses and training. Google has announced intended support for a shared training preference token, __usage_ai-training, in early 2027; this should not be assumed operational in November 2026. Check implementation status before relying on it.
AI access policies evolve. Maintain a dated policy register describing each provider, the intended use, the chosen rule and the evidence that the provider recognizes it. Robots.txt is neither a universal licensing contract nor a mechanism to erase data already collected or to compel an AI service to cite a website. The broader editorial and technical implications are explained in the GEO entry.
Availability, HTTP responses and crawl management
The robots.txt endpoint itself is an important dependency. A valid response with status 200 is straightforward; a redirect introduces another request and possible failure. The effects of missing files and server errors vary by protocol and implementation. RFC 9309 distinguishes unavailable responses such as 4xx from unreachable conditions such as server or network failures. Google documents additional behavior, including exceptions for rate limiting and the use of cached rules. Its documented parsing limit is 500 KiB. Do not use intermittent errors to communicate policy.
On a large e-commerce or publishing website, a crawl restriction can reduce requests to endless faceted navigation, duplicate search pages or generated combinations of parameters. But a small site is often better served by eliminating the URL explosion at its source. A crawl budget is not a fixed allowance that can be transferred mechanically from blocked URLs to important pages. Internal navigation, response speed, consistent status codes and useful content all affect whether crawling is productive.
Check the firewall and CDN separately. An allowed crawler that receives a browser challenge, a 403 response or an empty JavaScript shell may still be unable to retrieve the document. Conversely, a client can impersonate a familiar user agent, so use provider-supported verification mechanisms rather than relying on the header alone for privileged network access.
Testing a policy before deployment
Begin with an explicit inventory of representative URLs: the homepage, article and category pages, language variants, a filtered URL, a PDF, a stylesheet and a private area. For each crawler and URL, record the expected outcome, then compare it with the actual result. This is a small regression test for discoverability. A multilingual site should include both /wiki/robots-txt/ and /ro/wiki/robots-txt/ rather than assuming that the same slug implies the same policy.
curl -i https://example.com/robots.txt
curl -I https://example.com/article/
The first command exposes the policy response; the second inspects the article's headers, including any X-Robots-Tag. A HEAD request is useful for diagnosis but should be followed by a GET when behavior differs or the HTML needs inspection. Neither command by itself simulates the interpretation of every crawler.
Use the SEOsite Robots.txt Checker to inspect rules for a URL and selected crawler. Review Google Search Console for Google's actual crawl and indexing observations, and compare them with server logs after a change. Log evidence should distinguish verified automated clients from ordinary requests. A 200 response proves that a resource was delivered, not that it was indexed, selected for an answer or cited.
Keep the last working file under version control. Deploy changes with a recorded reason, test the most valuable public pages first and monitor requests and index coverage after the change. During migrations, avoid leaving temporary staging restrictions on the production host. If robots.txt is working as intended but visibility is poor, investigate indexing directives, canonicals, internal linking, content quality and the needs of the search audience rather than repeatedly adding crawler exceptions.