A robots.txt file is a plain text file at the root of your site that tells crawlers which URLs they may request. Search engines read it before they crawl, and so do many AI crawlers. A single wrong line can stop Google from crawling your whole site, so it’s worth getting right.
The file has also taken on a second job. You can now use it to decide which AI systems can train on your content and which can show it in their answers, but only for crawlers that choose to follow it.
This guide covers how crawlers read the file, when it helps SEO, copy-ready examples, how to test it, the common mistakes, and how to handle AI crawlers.
What a robots.txt file looks like
Here’s a simple file:
# Rules for all crawlers
User-agent: *
Disallow: /admin/
Disallow: /search
Allow: /admin/help/
Sitemap: https://www.example.com/sitemap.xml

Each block starts with one or more User-agent lines, followed by the rules for those crawlers. A block like this is called a group.
| Directive | What it does |
|---|---|
User-agent | Names the crawler the group applies to. * means any crawler without its own group |
Disallow | A path the crawler shouldn’t request |
Allow | A path the crawler may request, even inside a disallowed folder |
Sitemap | The full URL of your XML sitemap. It sits outside any group |
# | A comment. Crawlers ignore everything after it on that line |
Google supports two wildcards. * matches any sequence of characters, and $ marks the end of a URL, so Disallow: /*.pdf$ blocks every URL ending in .pdf.
Paths are case-sensitive, so Disallow: /Blog/ doesn’t block /blog/. Google ignores directives it doesn’t support, including crawl-delay and noindex.
How crawlers read robots.txt
Where the file lives
A crawler only looks for robots.txt at the root of a host, for example https://www.example.com/robots.txt. The file covers that protocol, host, and port only.
That means blog.example.com, shop.example.com, and http://example.com each need their own file. A file placed in a subfolder is ignored.

Which group a crawler follows
This is easy to get wrong. According to Google’s robots.txt specification, a crawler follows only the most specific group that matches its user agent, and ignores the rest. A group is a User-agent line and the rules listed under it, up to the next User-agent line.
Take this file:
User-agent: *
Disallow: /private/
Disallow: /checkout/
User-agent: Googlebot
Disallow: /private/
Googlebot has its own group, so it follows only that group. It can crawl /checkout/, because the rules under * don’t apply to it. If you add a group for a specific crawler, repeat every rule you want it to follow.
Which rule wins
When an Allow and a Disallow rule both match a URL, Google uses the rule with the longest, most specific path. If two matching rules are equally specific, Google uses the less restrictive one, which is Allow.
In the example file at the start of this guide, /admin/help/ is crawlable because Allow: /admin/help/ is more specific than Disallow: /admin/.
File size, caching, and errors
Google reads up to 500 kibibytes (KiB) of a robots.txt file and ignores anything after that. It generally caches the file for up to 24 hours, so changes aren’t picked up instantly.
What Google does when it can’t read the file depends on the HTTP status code it gets back:
| Response | What Google does |
|---|---|
| 200 (OK) | Follows the rules in the file |
| 404 or another 4xx error, except 429 | Acts as if there’s no robots.txt file, so nothing is blocked |
| 5xx error or 429 | Stops crawling the site for the first 12 hours while it retries. For the next 30 days, it uses the last good copy of the file if it has one |
A server error on robots.txt can pause crawling across the whole site, so it’s worth watching for. Our guide to HTTP status codes and SEO covers what each code means.

When robots.txt helps SEO, and when it doesn’t
Robots.txt controls crawling, not indexing. It’s useful for keeping crawlers out of URLs that waste their time, such as internal search results, endless filter combinations from faceted navigation, cart and checkout pages, and admin areas.
You’ll often hear that blocking these URLs frees up crawl budget for your important pages. That’s only partly true. In its crawl budget guide, Google says crawl budget mainly matters for sites with over a million unique pages that change weekly, or over 10,000 pages that change daily, and calls these rough estimates.
Google also says that blocking pages doesn’t usually move that budget to other pages, unless Google is already hitting your server’s crawl limit. Its advice is direct: “Don’t use robots.txt to temporarily reallocate crawl budget for other pages.” For most sites, a clean structure and good website crawlability matter more than tuning robots.txt.
Robots.txt also won’t keep a page out of search results: if other pages link to a blocked URL, Google can still index it without crawling it, usually with no description. Discussing blocked add-to-cart URLs, Google’s John Mueller said that even if they’re indexed, they’re “unlikely” to be shown in search, according to Search Engine Journal. If a page must stay out of results, use noindex instead.
Robots.txt vs noindex vs password protection
These three are often confused, and each does a different job.
| Goal | Use | Why |
|---|---|---|
| Stop crawlers wasting time on low-value URLs | Robots.txt | Saves crawl requests, but the URL can still be indexed |
| Keep a page out of search results | A noindex meta tag, or a noindex rule in the X-Robots-Tag HTTP header for files such as PDFs | The page must stay crawlable so Google can see the tag |
| Keep content private | Password protection or server authentication | Robots.txt is public, and not every crawler follows it |
| Remove a page for good | A 404 or 410 status code | Lets crawlers see that the page is gone |
Don’t combine robots.txt with noindex on the same page. If the page is blocked, Google never sees the noindex tag. Our guide to meta tags explains how noindex works.
How to create a robots.txt file
- Check whether you already have one. Go to
yourdomain.com/robots.txt. Many CMSs, including WordPress, create one automatically. - Decide what to block. List the sections that crawlers don’t need, such as admin pages, internal search, and filtered URLs. Leave CSS, JavaScript, and images crawlable.
- Write the rules. Use a plain text editor, or a generator such as SEOptimer’s robots.txt generator. Save the file as
robots.txt, encoded in UTF-8. - Upload it to the root of your site. On a CMS, use its built-in robots.txt setting or an SEO plugin if it has one.
- Check it once it’s live, using the steps in the testing section below.
Add your sitemap to robots.txt
Adding a Sitemap line helps crawlers find your sitemap without you having to submit it to every search engine. Use the full URL, and add one line per sitemap if you have several:
Sitemap: https://www.example.com/sitemap.xml
Sitemap: https://www.example.com/blog-sitemap.xml
The line can go anywhere in the file, because it doesn’t belong to a user-agent group. It doesn’t replace submitting your sitemap in Google Search Console, which also shows you sitemap errors.
Robots.txt examples you can copy
Replace example.com with your own domain, and test any file before you publish it.
Allow all crawlers
User-agent: *
Disallow:
Sitemap: https://www.example.com/sitemap.xml
An empty Disallow blocks nothing. Having no robots.txt file at all has the same effect, but an explicit file lets you add your sitemap.
Block admin pages and internal search
User-agent: *
Disallow: /admin/
Disallow: /search
Disallow: /*?q=
Disallow: /cart/
Sitemap: https://www.example.com/sitemap.xml
A typical WordPress file
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://www.example.com/wp-sitemap.xml
The Allow line keeps admin-ajax.php crawlable, because some themes and plugins load content through it. WordPress 5.5 and later adds the Sitemap line for you, though an SEO plugin may replace it with its own sitemap URL.
Block AI training crawlers but stay in AI search
User-agent: GPTBot
Disallow: /
User-agent: ClaudeBot
Disallow: /
User-agent: Google-Extended
Disallow: /
User-agent: Applebot-Extended
Disallow: /
User-agent: *
Disallow: /admin/
Sitemap: https://www.example.com/sitemap.xml
This blocks the training crawlers from OpenAI, Anthropic, and Apple, and opts out of Google using your content for Gemini. Search crawlers such as OAI-SearchBot, Claude-SearchBot, and PerplexityBot fall under the * group, so they can still reach your pages. Blocking Google-Extended also stops Gemini using your pages to ground its answers, so leave that group out if you want to appear in Gemini’s responses.
Block a staging site
User-agent: *
Disallow: /
Use this only on the staging host, and add password protection as well, because robots.txt doesn’t stop people or rogue bots from visiting. Make sure this file never goes live with your launch. Our website migration SEO checklist covers this step.
How to test your robots.txt file
Google retired its old robots.txt Tester in November 2023 and replaced it with the robots.txt report in Search Console.
To find it, open Search Console, go to Settings, and open the robots.txt report. It’s available for domain properties and for URL-prefix properties at the root of a site.

The report shows the robots.txt files Google found for the top 20 hosts on your property, with the fetch status, when each was last checked, its size, and any issues. According to Google’s help page, you can also request a recrawl from the menu next to a file, which is useful after you fix an error.
To check a single page, run it through the URL Inspection tool. If robots.txt blocks it, the result says so.
Search Console only shows what Google sees, and only for sites you’ve verified. The WebYes website audit checks whether your robots.txt file is valid, so you can catch syntax errors in each scan. It’s one of the checks in our step-by-step website audit guide.
Common robots.txt mistakes
Blocking pages crawlers need to see
Crawlers must be able to fetch a page to read the signals on it. Blocking a page in robots.txt hides those signals, which causes problems when you block:
- CSS and JavaScript files. Google renders pages much like a browser does. If it can’t load your scripts and styles, it may not see your content or layout properly. Our JavaScript SEO guide explains why.
- Pages with a canonical tag. Google can’t see the canonical on a blocked page, so it may index the wrong version.
- Redirected URLs. If the old URL is blocked, Google never sees the redirect and may keep the old URL in its index.
- Noindexed pages. As covered above, a blocked page’s noindex tag is never seen.
- Removed pages. Let crawlers see the 404 or 410 so they drop the URL.
- Alternate language pages. Google needs to crawl every version to read your hreflang tags.
Using robots.txt for the wrong job
- Adding noindex to robots.txt. Google stopped supporting it in September 2019, as it explained in a note on unsupported rules.
- Hiding sensitive content. Anyone can read your robots.txt, so listing private folders tells people where to look. Use authentication instead.
- Slowing Google down with crawl-delay. Google ignores it. Some other search engines support it, so it only helps for those.
Syntax errors
- Wrong case.
/Products/and/products/are different paths. - Missing or extra trailing slashes.
Disallow: /blogblocks/blog,/blog/, and/blog-tips.Disallow: /blog/blocks only URLs inside the folder, not/blogitself. - Careless wildcards.
Disallow: /*?blocks every URL with a parameter, including ones you may want crawled. - Full URLs in rules. Rules take paths, such as
/admin/, nothttps://www.example.com/admin/. Only theSitemapline uses a full URL. - A group with no user agent. Rules that don’t follow a
User-agentline are ignored. - Forgetting how group matching works. If you add a group for one crawler, it no longer follows your
*rules.
Staging sites and subdomains
- Assuming one file covers every subdomain. Each host needs its own file.
- Pushing the staging file live. A
Disallow: /copied from staging blocks your whole site. Check robots.txt as soon as you launch. - Leaving staging open. If staging uses your live file, its pages can be crawled and compete with your real ones.
- Keeping a CMS default without reading it. Some defaults block folders you need crawled, or don’t include your sitemap.
Managing AI crawlers with robots.txt
AI companies run several kinds of crawler, and robots.txt affects each one differently:
- Training crawlers collect content to train AI models.
- Search crawlers index pages so an AI assistant can find and cite them in answers.
- User-initiated fetchers visit a page when someone asks an assistant about it.
Blocking a training crawler doesn’t remove you from AI search, and blocking a search crawler doesn’t stop training. Our guide to AI crawlers goes into more detail.
| Company | Crawler | What it’s for | Follows robots.txt? |
|---|---|---|---|
| OpenAI | GPTBot | Training | Yes |
| OpenAI | OAI-SearchBot | ChatGPT search results | Yes. Changes can take about 24 hours |
| OpenAI | OAI-AdsBot | Checking ad landing pages | Not stated. OpenAI says it “only visits pages submitted as ads” |
| OpenAI | ChatGPT-User | Visits pages when a user asks | OpenAI says robots.txt rules “may not apply” |
| Anthropic | ClaudeBot | Training | Yes |
| Anthropic | Claude-SearchBot | Claude search results | Yes |
| Anthropic | Claude-User | Visits pages when a user asks | Yes. Blocking it stops Claude retrieving your pages for users |
| Google-Extended | Gemini training and grounding | Yes. Doesn’t affect Google Search | |
| Apple | Applebot-Extended | Opting out of Apple AI training | Yes. It doesn’t crawl, and doesn’t affect Apple search |
| Meta | Meta-ExternalAgent | Training AI models or indexing content | Yes |
| Meta | Meta-ExternalFetcher | Visits pages when a user asks | Meta says it “may bypass robots.txt rules” |
| Amazon | Amazonbot | Amazon services, and may be used for AI training | Yes |
| Amazon | Amzn-SearchBot | Amazon search experiences, not training | Yes |
| Perplexity | PerplexityBot | Perplexity search results, not training | Yes |
| Perplexity | Perplexity-User | Visits pages when a user asks | Perplexity says it “generally ignores robots.txt rules” |
Sources: OpenAI, Anthropic, Google, Apple, Meta, Amazon, and Perplexity.
Blocking Google-Extended stops Google using your content to train Gemini and to ground Gemini’s answers, but Google says it “does not impact a site’s inclusion in Google Search nor is it used as a ranking signal”. AI Overviews and AI Mode are part of Google Search, so Google-Extended doesn’t control them. The FAQ below covers how to opt out of those.
Robots.txt also has limits here: it only works for crawlers that choose to follow it, and blocking doesn’t undo past crawling. Anthropic, for example, says blocking ClaudeBot excludes your site’s “future material” from training. In an October 2026 episode of Google’s The Non-Canonical Cabinet podcast, Gary Illyes and Cherry Prommawin described robots.txt as “an access preference protocol” that doesn’t control what a system does with data it has already crawled.
You may also see a Content-Signal line, which Cloudflare introduced in September 2025. It states whether your content may be used for search, as input for AI answers (ai-input), or for AI training (ai-train), for example Content-Signal: search=yes, ai-train=no. These are preferences rather than blocks, and John Mueller said on Reddit that, as far as he knew, no crawlers or LLMs use it, and that it “just adds bloat” to the file.
Check your firewall, too
An Allow rule only helps if the crawler can reach your site. Firewalls, CDNs, and bot protection services can turn AI crawlers away before they ever read robots.txt, so a crawler you’ve allowed may still be blocked.
If you want to appear in AI answers, check that your firewall and bot protection allow the search crawlers you’ve allowed in robots.txt. Our guides to answer engine optimisation and AI search visibility cover what else affects whether you’re cited.
What about llms.txt?
llms.txt is a proposed file that lists the pages you’d like AI tools to read. Unlike robots.txt, it doesn’t allow or block anything. Mueller has said Google doesn’t use it, and we’ve looked at whether it makes any difference in does llms.txt improve rankings?
FAQs
No. Without one, crawlers assume they can crawl everything, which is fine for many small sites. A file is still useful for blocking low-value URLs, managing AI crawlers, and pointing crawlers to your sitemap.
No. It stops Google crawling the page, but the URL can still be indexed if other pages link to it. Use a noindex tag, and keep the page crawlable until Google has dropped it.
Partly. Blocking crawlers such as GPTBot, ClaudeBot, and Google-Extended works for companies that follow robots.txt, but it only applies from the point you block them. It doesn’t remove content that was collected before, and it doesn’t stop crawlers that ignore robots.txt.
No. Google-Extended doesn’t affect Google Search, and AI Overviews are part of Search. To opt out of AI Overviews and AI Mode, use the Search generative AI control in Search Console, under Settings, which Google rolled out to all sites on 31 August 2026. Google says it isn’t used as a ranking or inclusion signal for the rest of Search.
Google generally caches robots.txt for up to 24 hours. If you’ve fixed an urgent error, request a recrawl from the robots.txt report in Search Console.
It depends on your goals. If you want to be cited in AI answers, allow the search crawlers and decide separately about training crawlers. If your content is your product, such as paid research, blocking training crawlers may make sense, alongside firewall rules for crawlers that ignore robots.txt.