Table of contents
- Quick summary
- What a robots.txt file can and cannot do
- Decide first: three jobs, three tokens
- Path 1: write the file by hand
- Path 2: use your platform's editor
- Docusaurus
- A subpath robots.txt is not a robots.txt
- Where baseUrl puts your file
- Write the rules into static/robots.txt
- Deploying under a repository path
- Build the file from siteConfig
- The Docusaurus project's own site names no crawler
- Read it back from the origin root
- Wix
- Wix keeps rewriting the file you are about to edit
- Open the Robots.txt Editor
- A named group replaces the defaults, it does not extend them
- Wix's four example names, checked against 2026
- Rules that keep you in the answers and out of the training set
- Read the file back from your own domain
- When the editor is not the problem
- WordPress
- Find out which file you are serving
- ThinkRank (ours)
- Yoast SEO
- Rank Math
- All in One SEO
- No SEO plugin: one small must-use plugin
- The page cache can flatten the file
- Check it from outside
- Next.js
- App Router: the starter as app/robots.ts
- Pages Router: public/robots.txt
- The trap: public/robots.txt and app/robots.ts together
- The trap: proxy.ts redirects robots.txt to your login page
- Check it from outside
- Verify it did what you meant
- Two variants of the starter
- When a rule does not seem to work
- Maintenance
- What to do next
Most sites that "block AI" with a robots.txt file end up with one of two outcomes: a file that blocks nothing because a bot name is misspelled, or a file that blocks the crawlers that would have sent them traffic. This guide gives you a starter file you can paste in, the three decisions that shape it, and a two-minute test that proves each rule does what you meant. The starter below takes about 10 minutes to adapt and ship.
Updated on 27 November 2026: added a Next.js section with app/robots.ts, the Pages Router file and two traps we reproduced on a fresh build. On 26 November we added a WordPress section covering where the file really comes from, Yoast, Rank Math, AIOSEO, ThinkRank and a filter of your own, and a page-cache trap we found on our own site. On 5 November we added the Docusaurus and Wix sections, folded in from the platform guides that used to sit at their own URLs.
Quick summary
| If you want to... | Block these tokens | Leave these open | Time |
|---|---|---|---|
| Stay in AI answers, stay out of training sets | GPTBot, ClaudeBot, CCBot, Google-Extended, Applebot-Extended, meta-externalagent, Amazonbot | OAI-SearchBot, Claude-SearchBot, PerplexityBot, ChatGPT-User, Claude-User, Googlebot | 10 min |
| Be open to everything | Nothing | Everything | 2 min (verify only) |
| Fix it on WordPress | Same tokens, written where WordPress actually serves them | Check for a physical file and a page cache first | 15 min |
| Fix it on Next.js | Same tokens, as rules in app/robots.ts | Delete a leftover public/robots.txt; exclude robots.txt from proxy.ts | 10 min |
| Opt out of AI entirely | All of the above plus the search and user-fetch tokens | Googlebot, bingbot | 15 min |
Using WordPress, Next.js, Docusaurus or Wix? Jump to WordPress, Next.js, Docusaurus or Wix. If you are unsure whether the Sitemap line is worth keeping, see what 782 robots.txt files showed about declaring a sitemap.
Expert guidance in one line: OpenAI's crawler documentation says each of its settings is independent, so a site can allow OAI-SearchBot to appear in ChatGPT search while disallowing GPTBot. Anthropic's crawler help page draws the same split between ClaudeBot (training) and Claude-User (answering a person's question). Treat each operator as three bots, not one.
Check your current file first: npx aiscan-cli yoursite.com reports B1 (Content Signals) and B2 (explicit AI bot rules) in about 20 seconds.
What a robots.txt file can and cannot do
RFC 9309 defines the format and says plainly that the Robots Exclusion Protocol is not a substitute for valid content security measures. A rule is a request. A well-behaved crawler reads it and complies. A badly behaved one ignores it.
That is not a theory. In AIScan's measurement of 40 hosts, a full Disallow: / was backed by an actual refusal at the server edge only 45% to 67% of the time, depending on the bot (see Does blocking AI training protect your content?). Use robots.txt to state your policy. Use your CDN or firewall if you need to enforce it. A noai meta tag is not a substitute for either: none of eight AI crawler operators documents it (see do noai and noimageai meta tags stop AI crawlers?).
Three mechanics decide whether your file works:
- A bot obeys the most specific group that names it. Per RFC 9309 section 2.2.1, if no group matches a bot's token, it falls back to the
*group. If a group does match, the*group no longer applies to it. Add a named group forOAI-SearchBotand it stops inheriting yourDisallow: /admin/line from*, unless you repeat it. - Tokens are not user-agent strings. Google's crawler documentation says
Google-Extendedhas no separate HTTP user agent. Crawling uses existing Google strings and the token only controls how the content is used. Applebot-Extended works the same way. A namedGoogle-Extendedgroup also outranks the new shared training token at Google, so anAllow: /here cancels that opt-out; see the precedence table. - Some user-triggered fetchers ignore robots.txt by design. Perplexity documents that
Perplexity-Usergenerally ignores it. OpenAI describesChatGPT-Useras visiting pages when a person asks, not crawling automatically. The full list of 33 tokens, with the dates each was checked, is in the AI crawler user-agent list.
Decide first: three jobs, three tokens
| Operator | Training | Search index | Live fetch for a person |
|---|---|---|---|
| OpenAI | GPTBot | OAI-SearchBot | ChatGPT-User |
| Anthropic | ClaudeBot | Claude-SearchBot | Claude-User |
| Perplexity | none | PerplexityBot | Perplexity-User |
| Amazon | Amazonbot | Amzn-SearchBot | Amzn-User |
| Mistral | MistralAI-Training | MistralAI-Index | MistralAI-User |
Google-Extended (token only) | Googlebot | Google-Agent | |
| Common Crawl | CCBot | none | none |
Blocking the first column keeps you out of future training sets. Blocking the second removes you from that operator's search answers. Blocking the third stops an assistant fetching your page when a person asks about it. Anthropic states that disabling Claude-User may reduce your site's visibility. Most publishers who want citations block the first column and leave the other two open. That is the profile in the starter file.
Training exclusion applies to future collection. Nothing in a robots.txt file removes content a crawler already holds. A shared training token, __usage_ai-training, is also on the way (Google and OpenAI announced plans on 30 Oct 2026); where to put it without blocking your crawlers is in the __usage_ai-training token, tested.
Path 1: write the file by hand
Use this on any host where you can edit the file at the site root.
- Open or create
robots.txtat your site root. It must be reachable athttps://yoursite.com/robots.txt, all lowercase, and return a 200 withtext/plain. - Paste the starter below, replace
example.comand the twoDisallowpaths with your own private paths. - Keep your existing
Sitemap:line. Crawlers may read it, but RFC 9309 does not define it, so do not rely on it as a rule. - Save and deploy. OpenAI says its systems take about 24 hours to pick up a change, so do not judge the result from your logs the same afternoon.
User-agent: *
Disallow: /admin/
Disallow: /cart/
# Training crawlers: opt out
User-agent: GPTBot
User-agent: ClaudeBot
User-agent: CCBot
User-agent: Google-Extended
User-agent: Applebot-Extended
User-agent: meta-externalagent
User-agent: Amazonbot
User-agent: MistralAI-Training
Disallow: /
# Search crawlers: stay visible (repeat the private paths from the * group)
User-agent: OAI-SearchBot
User-agent: Claude-SearchBot
User-agent: PerplexityBot
User-agent: Amzn-SearchBot
User-agent: MistralAI-Index
Disallow: /admin/
Disallow: /cart/
Sitemap: https://example.com/sitemap.xml
Several User-agent lines above one set of rules is valid under RFC 9309 and keeps the file short. Bots with no group, such as ChatGPT-User, Claude-User and Googlebot, fall through to * and are only kept out of /admin/ and /cart/.
To declare your policy in one extra line, add a Content Signal. Cloudflare's proposal uses Content-Signal: search=yes, ai-train=no, ai-input=yes. It is a draft and not part of RFC 9309, so treat it as a statement of intent. AIScan reports it as check B1 and it is informational only.
Path 2: use your platform's editor
WordPress. Three plugins often compete to write robots.txt and the last one loaded wins. ThinkRank manages robots.txt, robots meta, schema and llms.txt from one plugin, so there is a single place to paste the starter, and it imports settings from Rank Math, Yoast, AIOSEO and SEOPress so nothing is re-entered. Rank Math and Yoast both have a robots.txt editor too and are fine if you already run one of them. Whichever you use, deactivate the other editors so only one file is served, then paste the starter. The WordPress section below has the exact steps for each plugin, a filter for sites without one, and what 217 WordPress sites in our scans actually serve.
Shopify. Shopify's robots.txt.liquid documentation says adding that template replaces the generated file. In the theme code editor, right-click the Templates folder, choose New File, name it robots.txt.liquid, and save a copy of your current /robots.txt output first so you can compare. Keep Shopify's default rules in the template and add the training groups from the starter. For the files that sit beside robots.txt, StoreSEO generates llms.txt from live products, collections, pages and articles and has an agents.md editor.
WordPress, Next.js, Docusaurus and Wix. These four have sections of their own below: WordPress for a virtual file, a physical file and a page cache that compete, Next.js for app/robots.ts and the leftover public/robots.txt that silently wins, Docusaurus for the baseUrl trap and Wix for a generated file that your named groups sit beside. Other platform editors rewrite defaults in different ways, so read the file back after every save.
Docusaurus
Docusaurus gives you somewhere to put a robots.txt in about ten seconds. Making sure a crawler ever reads it is the harder half, because the most common Docusaurus deployment shape files the rules at a URL where they carry no force at all. We re-checked the Docusaurus static assets documentation on 5 November 2026 and the behaviour below still holds.
The one thing to get right: the rules have to answer at https://yourdomain.com/robots.txt, not at https://yourdomain.com/your-project/robots.txt.
A subpath robots.txt is not a robots.txt
RFC 9309 says the rules MUST be accessible in a file named "/robots.txt" (all lowercase) in the top-level path of the service. A crawler asks the authority for /robots.txt and stops. There is no second location and no fallback. If your rules answer one directory down, a compliant crawler never sees them, and the RFC is equally clear about the result: if no group matches and no * group exists, "or no groups are present at all, no rules apply." Your allow and deny lines do not fail loudly. They simply do not exist.
That gap bites harder here than on most platforms. The llms.txt specification allows a file at any subpath, so a file under a repository path is still valid there (see llms.txt on Docusaurus). The Robots Exclusion Protocol allows nothing of the kind.
Where baseUrl puts your file
Docusaurus copies the static folder wholesale. Its documentation says every file in that directory is copied into the root of the generated build folder with the directory hierarchy preserved, and the build root is served under baseUrl:
baseUrl in your config | static/robots.txt answers at | Crawler reads it? |
|---|---|---|
'/' | https://yoursite.com/robots.txt | Yes |
'/my-project/' | https://yoursite.com/my-project/robots.txt | No |
A site published at https://my-org.com/my-project/ needs url set to https://my-org.com/ and baseUrl set to /my-project/. That configuration is correct, documented, and the reason your rules are invisible.
Write the rules into static/robots.txt
Create the file at static/robots.txt next to docusaurus.config.js. Other source folders added through staticDirectories behave identically, so staticDirectories: ['public', 'static'] lets you keep it in public/ instead.
User-agent: OAI-SearchBot
Allow: /
User-agent: PerplexityBot
Allow: /
User-agent: GPTBot
Disallow: /
User-agent: ClaudeBot
Disallow: /
User-agent: Google-Extended
Disallow: /
Sitemap: https://yoursite.com/sitemap.xml
Each crawler gets a named group of its own, because a scanner cannot tell a deliberate allow from an absent rule when all it finds is User-agent: *. The retrieval bots sit apart from the training bots, so you can change your mind about model training without removing yourself from the answers those tools cite. The verified AI crawler user-agent list has every current token, and the crawler category breakdown explains which bot belongs in which group.
Deploying under a repository path
If your docs live at org.github.io/project/, no edit to static/robots.txt can fix this, because the origin root belongs to the account rather than to your repository. Checked on 6 September 2026, facebook.github.io/robots.txt and microsoft.github.io/robots.txt both return 404: even those accounts publish no rules at the only address that counts.
| Situation | What to do |
|---|---|
| Docs on a project path you control the domain for | Attach a custom domain, set baseUrl: '/', redeploy |
| Docs on Netlify, Vercel, Render or Cloudflare Pages | Already at the root; static/robots.txt works as written |
Docs genuinely stuck on org.github.io/project/ | Publish rules on the user or organisation site instead, and accept they cover every repository |
A user or organisation Pages site is served at the root, so a robots.txt there is read. It also governs everything else that account publishes, which is a real trade rather than a workaround.
Build the file from siteConfig
Hard-coding the Sitemap: line means it drifts the first time the domain changes. Docusaurus exposes a plugin lifecycle hook, postBuild(props), that runs once the build is finished, with siteConfig, baseUrl and outDir on the props object:
import fs from 'fs';
import path from 'path';
export default function robotsPlugin() {
return {
name: 'robots-txt',
async postBuild({siteConfig, baseUrl, outDir}) {
if (baseUrl !== '/') {
throw new Error(`robots.txt is unreachable under baseUrl "${baseUrl}"`);
}
const rules = `User-agent: OAI-SearchBot\nAllow: /\n\nUser-agent: GPTBot\nDisallow: /\n\nSitemap: ${siteConfig.url}/sitemap.xml\n`;
fs.writeFileSync(path.join(outDir, 'robots.txt'), rules);
},
};
}
The thrown error is the useful part. It turns the silent subpath problem into a failed build.
The Docusaurus project's own site names no crawler
Fetched from docusaurus.io/robots.txt on 6 September 2026, the file returned 200 and text/plain and ran to twenty lines, every one of them a comment: the Content Signals licence preamble and nothing else. Zero User-agent lines, zero Allow or Disallow rules, no Sitemap line. The file exists and a status-code check calls it healthy while it says nothing about AI crawlers.
Read it back from the origin root
npx aiscan-cli yoursite.com
curl -s -o /dev/null -w '%{http_code} %{content_type}\n' https://yoursite.com/robots.txt
curl -s https://yoursite.com/robots.txt | grep -iE 'GPTBot|SearchBot|Perplexity|Sitemap'
Read D1 for whether a parseable robots.txt answers at all, and B2 for whether it names AI crawlers explicitly. B2 fails when the file exists but carries only a * group, and when baseUrl hid the file. The first curl must print 200 text/plain. If it prints 404 while the same file answers under your project path, baseUrl is the cause and no edit to the file will change it. AIScan asks the origin root only, so a Docusaurus site on a project path shows a bare HTTP 404 in the evidence field rather than "your file is one directory too deep". That is a known limit of the scanner, not a verdict on your file.
Wix
Wix writes your robots.txt for you. Fetched on 7 September 2026, the file at www.wix.com/robots.txt ran to 90 non-empty lines: one User-agent: * group, 87 Disallow rules, and a single Sitemap: line at the bottom. Adding a rule for GPTBot or ClaudeBot takes about two minutes in the Robots.txt Editor, and it does something most guides never mention: the crawler you just named stops reading every one of those 87 lines. We re-checked Wix's Robots.txt Editor article on 5 November 2026 and the path below is unchanged.
| If you want to | Do this on Wix | Where it lives | Time |
|---|---|---|---|
| Stop AI training crawlers | Add named groups for GPTBot, ClaudeBot, CCBot, Google-Extended | SEO & GEO > Tools and settings > Robots.txt Editor | 2 min |
| Stay citable in ChatGPT and Perplexity | Leave OAI-SearchBot and PerplexityBot out of your deny list | Same editor | 0 min |
| Undo a bad edit | Reset to Default, then Reset | Same editor | 1 min |
| Keep one page out of AI Overviews | Tick nosnippet | Editor > Pages & Menu > SEO basics > Advanced SEO | 1 min |
| Confirm the rules are live | npx aiscan-cli yoursite.com, read rows D1 and B2 | aiscan.site | 1 min |
Wix keeps rewriting the file you are about to edit
Wix says it maintains the file continuously: "If you need to update a page, Wix automatically updates your robots.txt after you publish the page. If you change your site's settings, your robots.txt file is updated immediately." That is the opposite of how the other generated file on Wix behaves. As covered in publishing a valid llms.txt on Wix, Wix says that once you edit llms.txt, "it will stop updating automatically so your changes are preserved." Robots.txt carries no such lock: your named groups sit alongside a * group Wix goes on regenerating around them. Wix also puts a warning above the procedure worth repeating: "Wix Customer Care cannot help you with any changes you make to your robots.txt file."
Open the Robots.txt Editor
- Go to SEO & GEO in your site's dashboard.
- Scroll down to Tools and settings.
- Click Robots.txt Editor.
- Click View File.
- Type your directives under This is your current file.
- Click Save Changes, then Save.
To undo everything, repeat the first four clicks, then Reset to Default and Reset. There is no file manager and no FTP on Wix, so this panel is the only way in.
A named group replaces the defaults, it does not extend them
RFC 9309 section 2.2.1 states: "Crawlers MUST use case-insensitive matching to find the group that matches the product token and then obey the rules of the group." Groups for different tokens do not stack; the spec merges only groups matching the same token.
Every rule Wix generated sits under User-agent: *. The moment you add User-agent: GPTBot, that crawler reads your group and ignores the * group entirely. A group of Disallow: / is harmless, because you blocked everything anyway. Write Allow: / under a named token and you have handed that crawler the internal paths Wix was keeping shut.
The safe shape on Wix: name a crawler only to deny it, and let the rest fall through to *. One syntax rule from section 2.2.1 catches people out: a product token "MUST contain only uppercase and lowercase letters", plus hyphen and underscore. No slashes, no version numbers, no wildcards in the name.
Wix's four example names, checked against 2026
Wix's article Blocking AI Crawlers from Your Site gives a worked example: CCBot, GPTBot, ChatGPT-User and BingAI, each with Disallow: /. Checked against our AI crawler user-agent list:
| Token in Wix's example | What it actually does | Worth blocking? |
|---|---|---|
GPTBot | OpenAI training crawler | Yes, if you are opting out of training |
CCBot | Common Crawl, the open training corpus | Yes, same reason |
ChatGPT-User | Live fetch triggered by a person in ChatGPT | Usually no, this is a visitor |
BingAI | Appears in no operator token list we hold | No effect either way |
Missing from the example and crawling in 2026: ClaudeBot, PerplexityBot, Google-Extended, meta-externalagent and Applebot-Extended. Wix's own FAQ is honest about the ceiling: "some crawlers may ignore these directives, so it's not an airtight solution."
Rules that keep you in the answers and out of the training set
Paste this under This is your current file, below what is already there:
User-agent: GPTBot
Disallow: /
User-agent: ClaudeBot
Disallow: /
User-agent: CCBot
Disallow: /
User-agent: Google-Extended
Disallow: /
OAI-SearchBot, PerplexityBot and Bingbot are unlisted, so they keep matching * and keep indexing you. Block OAI-SearchBot by accident and you leave the surface you were trying to win.
Read the file back from your own domain
Assert the content type, not the status code:
curl -sI https://yoursite.com/robots.txt
curl -s https://yoursite.com/robots.txt | grep -A1 -i 'gptbot'
A working file answers 200 with content-type: text/plain. If you get text/html, you are reading an error page, not a file. The second command should print the two lines you typed. An empty result means the save did not commit; reopen View File rather than typing it somewhere else. The envelope matters as much as the rules, and serving robots.txt with the right status and content type covers what crawlers do on a 403, 503 or HTML response.
When the editor is not the problem
Wix is direct that most robots.txt complaints are not robots.txt complaints. If Wix Site Inspection or Google Search Console reports Blocked by robots.txt, Wix says "you don't need to edit your robots.txt file, especially if you never edited it before."
| What you see | What it usually is |
|---|---|
| Blocked by robots.txt on a page you never named | Indexing switched off for that page in the editor or in SEO Settings |
| A page missing from the file's reach | The page is password protected or members only |
| Your rules are there but a bot still crawls | A crawler that ignores the protocol, which Wix concedes happens |
| A page still quoted in an AI Overview | robots.txt does not govern snippets, nosnippet does |
For that last row, in the editor go to Pages & Menu > More Actions > SEO basics > Advanced SEO > Robots meta tag and tick nosnippet, which Wix describes as preventing a page's content "from being used as a direct input for AI overviews". One caution before denying broadly: Wix warns that blocking AI crawlers "may limit NLWeb functionality, as AI agents need access to view your structured content." The scan cannot see your server logs or whether a crawler obeyed, and Wix does not expose logs.
WordPress
On WordPress, robots.txt can come from three places. WordPress builds a virtual file in PHP, an SEO plugin edits that virtual file, or there is a real robots.txt in the web root that the web server sends before WordPress runs. Rules you paste into one of these do nothing while another one is the file being served. That explains most "I added GPTBot and nothing changed" reports on WordPress.
The numbers bear it out. In AIScan's scan database on 26 November 2026 (887 hosts, the latest site scan per host on rubric 2026.08.2, our own site excluded), 61 of 217 WordPress sites pass B2 (28%). Next.js sites pass 97 of 222 (44%) and Astro sites 34 of 52 (65%). For 153 of the WordPress failures the evidence line is the same: "0 known AI agent(s) addressed in robots.txt". Having an SEO plugin installed makes little difference:
| Detected SEO plugin (WordPress, 26 Nov 2026) | Sites | B2 pass | Share |
|---|---|---|---|
| None detected | 58 | 18 | 31% |
| Rank Math | 79 | 20 | 25% |
| Yoast SEO | 66 | 16 | 24% |
| All in One SEO | 8 | 4 | 50% |
| ThinkRank | 5 | 2 | 40% |
The last two rows are too small to read anything into. The size of the files says more: 55 of the 217 WordPress sites serve a robots.txt of 130 bytes or less. That is the size of WordPress's own default (67 bytes) plus one Sitemap: line. The scan stores the size, not the text, so treat that as an estimate of untouched defaults.
Find out which file you are serving
WordPress's do_robots() prints three lines, User-agent: *, Disallow: /wp-admin/ and Allow: /wp-admin/admin-ajax.php, and passes them through the robots_txt filter. Since WordPress 5.5, core's sitemap code hooks that same filter and adds a Sitemap: line pointing at /wp-sitemap.xml. Yoast's help page says the same thing from the other side: "WordPress generates a virtual robots.txt file if the site root does not contain a physical file."
- Read the first lines. Run
curl -s https://yoursite.com/robots.txt | head -5.# START YOAST BLOCKmeans Yoast wrote a physical file.# Robots.txt generated by ThinkRank SEOmeans ThinkRank. The three core lines and nothing else means no one has touched it. - Look in the web root. In your host's file manager or over SFTP, open the folder that holds
wp-config.php. Ifrobots.txtis there, it is the file being served, and no plugin setting or filter will change it. With WP-CLI:wp eval 'echo file_exists( ABSPATH . "robots.txt" ) ? "physical" : "virtual";'. - Don't go by headers alone. A static file normally comes with
Last-ModifiedandETagheaders and PHP output does not, but a page cache adds both. Our own WordPress site, masifrahman.com, serves its file through WordPress, and on 26 November it came back withlast-modified,etagandcache-control: public, max-age=14400all the same.
Then use the path below that matches your setup. Keep one editor. If two plugins both offer a robots.txt screen, turn the feature off in one of them.
ThinkRank (ours)
ThinkRank is our WordPress SEO plugin. It manages robots.txt and robots meta in the same plugin as schema, sitemaps and llms.txt, so one plugin writes both the AI crawler rules and the sitemap lines. Its Pro plan adds a switch per AI crawler that is written into robots.txt "without touching the rest of it". If you are moving from Rank Math, Yoast, AIOSEO or SEOPress, it imports their settings first and shows you what it found before writing anything.
- Delete any physical
robots.txtfrom the web root (keep a copy) so the generated file is the one served. - Open ThinkRank's robots.txt settings and paste the training and search groups from the starter above the
Sitemap:lines. - Or, on Pro, use the per-crawler switches: off for training tokens such as
GPTBot,ClaudeBotandCCBot, on forOAI-SearchBot,Claude-SearchBotandPerplexityBot. - Save, purge your page cache, and read the file back (see the cache step below).
Yoast SEO
- In the dashboard go to Yoast SEO > Tools > File editor. Yoast's help page warns that this menu "will not appear if your WordPress install has disabled file editing", for example with
DISALLOW_FILE_EDITinwp-config.php. - Click Create robots.txt file if there is none yet. Yoast swaps the WordPress default for its own block:
User-agent: *, an emptyDisallow:, and yourSitemap:line, between# START YOAST BLOCKand# END YOAST BLOCK. - Paste the starter's named groups below the Yoast block. In each named group, repeat
Disallow: /wp-admin/andAllow: /wp-admin/admin-ajax.php, because a named group replaces the*group for that bot instead of adding to it. - Save. This writes a physical file, so from now on every filter and every other plugin's robots.txt setting is ignored.
Rank Math
- Go to Rank Math SEO and check that Advanced Mode is on (the switch at the top right).
- Open General Settings > Edit robots.txt. Rank Math's guide says it edits a virtual file, and that you first "need to delete the actual robots.txt file (if any) from your website's root folder".
- Paste the starter's groups, with the WordPress paths in place of
/admin/and/cart/. - Save, purge the cache and read the file back.
All in One SEO
- Go to All in One SEO > Tools > Robots.txt Editor and turn on Enable Custom Robots.txt.
- Add each line as a rule in the rule builder (user agent, directive, value), or use the import option to paste the starter in one go. AIOSEO's documentation says it adds rules to the robots.txt WordPress generates and does not write a file.
- Save and read the file back.
No SEO plugin: one small must-use plugin
If you'd rather not run a plugin for this, add the rules through the robots_txt filter yourself. Save this as wp-content/mu-plugins/ai-crawler-rules.php. WordPress loads every file in mu-plugins without activation.
<?php
/**
* Plugin Name: AI crawler rules
* Description: Adds named AI crawler groups to the robots.txt WordPress generates.
*/
add_filter( 'robots_txt', function ( $output, $is_public ) {
if ( ! $is_public ) {
return $output; // "Discourage search engines" is ticked: change nothing.
}
$rules = <<<'TXT'
# Training crawlers: opt out
User-agent: GPTBot
User-agent: ClaudeBot
User-agent: CCBot
User-agent: Google-Extended
User-agent: Applebot-Extended
User-agent: meta-externalagent
User-agent: Amazonbot
User-agent: MistralAI-Training
Disallow: /
# Search crawlers: stay visible (repeat the private paths from the * group)
User-agent: OAI-SearchBot
User-agent: Claude-SearchBot
User-agent: PerplexityBot
User-agent: Amzn-SearchBot
User-agent: MistralAI-Index
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
TXT;
return $output . $rules . "\n";
}, 20, 2 );
Priority 20 runs after core's sitemap line (priority 0), so the Sitemap: line survives. We passed core's default output through this filter on PHP 8.3.6 on 26 November 2026, with a small stand-in for the hook functions rather than a full WordPress install. The result was 25 lines. Python's robotparser read it as GPTBot and ClaudeBot blocked everywhere, OAI-SearchBot, PerplexityBot and Googlebot allowed except under /wp-admin/, and one sitemap. This filter only runs while there is no physical robots.txt in the web root.
The page cache can flatten the file
This one we found on our own site while writing this section. On 26 November 2026 at 08:07 UTC, masifrahman.com's robots.txt was correct when it skipped the cache: 86 lines from ThinkRank. The copy that Googlebot, GPTBot and plain curl actually got was the page cache's: 1,712 bytes on one line, every line break turned into a space, with an HTML comment from the cache plugin added at the end. Because the file starts with #, a parser reads that whole line as a comment. All 16 named groups, the /wp-admin/ rules and the five Sitemap: lines are lost. robotparser answered "allowed" for every bot on every path. We have reported it to the cache plugin's developers.
| Request, 26 Nov 2026 | Cache header | Lines | Rules a parser sees |
|---|---|---|---|
/robots.txt (Googlebot, GPTBot, curl) | HIT | 1 | none |
/robots.txt?nocache=… | BYPASS | 86 | all |
- Exclude
/robots.txtfrom page caching and from HTML minification in your cache plugin, and at your CDN if it caches text files. - Purge the cache.
- Run
curl -s https://yoursite.com/robots.txt | wc -l. One line for a file that should have dozens means it has been flattened.
AIScan's B2 counts the bot names it finds in the file. On 26 November it still passed our flattened file ("13 known AI agent(s) addressed"), so run the line count as well as the scan. We have filed that with the scanner team.
Check it from outside
Use the scan and the hand checks in the next section. Our WordPress platform page collects the other WordPress guides. If a rule is right but a bot is still refused, or still gets in, the cause is usually a firewall rather than robots.txt: see when a WordPress security plugin blocks AI crawlers. For the exact token names, see the 2026 AI crawler user-agent list. Before you block a training token, read what the usage-based training token in robots.txt changes.
Next.js
On Next.js you usually don't edit a robots.txt file at all. In the App Router, app/robots.ts returns an object and Next.js writes the file for you at build time. The Pages Router has no such convention, so there you put a plain robots.txt in public/. Either works. Trouble starts when a project has both, or when a proxy.ts sign-in gate catches /robots.txt before Next.js can serve it.
In AIScan's scan database on 27 November 2026 (891 hosts, the latest site scan per host on rubric 2026.08.2, our own site excluded), 98 of 223 Next.js sites pass B2 (44%), 3 are partial and 122 fail. Every failure has the same evidence line, "0 known AI agent(s) addressed in robots.txt". D1 shows where those files come from: 13 Next.js sites return a 404 for /robots.txt and 11 serve one without a Sitemap: line. File size tells the rest:
| robots.txt size (Next.js, 27 Nov 2026) | Sites | B2 pass | B2 fail |
|---|---|---|---|
| No file (404) | 13 | 0 | 13 |
| 100 bytes or less | 30 | 0 | 30 |
| 101 to 300 bytes | 58 | 2 | 54 |
| 301 to 1,000 bytes | 72 | 59 | 13 |
| Over 1,000 bytes | 50 | 37 | 12 |
The example in the Next.js docs (User-Agent: *, Allow: /, Disallow: /private/, one Sitemap: line) comes to about 80 bytes. Not one of the 30 Next.js files at that size names an AI crawler. The scan keeps the size, not the text, so read this as a sign of copied defaults, not proof.
Everything below was built on 27 November 2026 with a fresh create-next-app (Next.js 16.4.6, App Router, TypeScript), then next build and next start on localhost. Each response was read back with curl.
App Router: the starter as app/robots.ts
The robots file convention takes rules as one object or an array. userAgent, allow and disallow each take a string or an array of strings, and sitemap and host sit at the top level. This is the starter from Path 1, the three jobs written as three rules:
// app/robots.ts
import type { MetadataRoute } from 'next'
const PRIVATE = ['/admin/', '/cart/']
export default function robots(): MetadataRoute.Robots {
return {
rules: [
{ userAgent: '*', disallow: PRIVATE },
// Training crawlers: opt out
{
userAgent: [
'GPTBot', 'ClaudeBot', 'CCBot', 'Google-Extended',
'Applebot-Extended', 'meta-externalagent', 'Amazonbot',
'MistralAI-Training',
],
disallow: '/',
},
// Search crawlers: stay visible, keep the private paths
{
userAgent: [
'OAI-SearchBot', 'Claude-SearchBot', 'PerplexityBot',
'Amzn-SearchBot', 'MistralAI-Index',
],
disallow: PRIVATE,
},
],
sitemap: 'https://example.com/sitemap.xml',
}
}
- Save that as
app/robots.ts, withPRIVATEset to your own private paths and the sitemap URL set to yours. - Run
next build. The route list should show○ /robots.txt, a static route. - Run
next startandcurl -s http://localhost:3000/robots.txt.
Our build returned 200, content-type: text/plain and these 23 lines (477 bytes):
User-Agent: *
Disallow: /admin/
Disallow: /cart/
User-Agent: GPTBot
User-Agent: ClaudeBot
User-Agent: CCBot
User-Agent: Google-Extended
User-Agent: Applebot-Extended
User-Agent: meta-externalagent
User-Agent: Amazonbot
User-Agent: MistralAI-Training
Disallow: /
User-Agent: OAI-SearchBot
User-Agent: Claude-SearchBot
User-Agent: PerplexityBot
User-Agent: Amzn-SearchBot
User-Agent: MistralAI-Index
Disallow: /admin/
Disallow: /cart/
Sitemap: https://example.com/sitemap.xml
That is the same rule set as the hand-written starter, and robotparser gave the same answers: False False for GPTBot and ClaudeBot, True False for OAI-SearchBot, PerplexityBot and Googlebot. One detail differs from the docs. Their sample output for userAgent: ['Applebot', 'Bingbot'] shows two separate groups with the rule repeated. Version 16.4.6 printed one group with stacked User-Agent lines. Both are valid under RFC 9309, so this changes nothing for a crawler, but don't be surprised when your output doesn't match the docs line for line.
The MetadataRoute.Robots type has no field for a Content Signal line. Since 16.3.0, each rule takes an other object for directives outside the standard, which Next.js passes through unchecked and prints inside that rule's group. If you want Content-Signal: as a file-wide line, use a static app/robots.txt instead (the convention accepts a plain file in the same place).
Pages Router: public/robots.txt
The public folder docs for the Pages Router name robots.txt as one of the files that folder is for.
- Paste the Path 1 starter into
public/robots.txt. - Deploy, then fetch
/robots.txt. Our build served the public file withContent-Type: text/plain; charset=UTF-8andCache-Control: public, max-age=0.
This also works on the App Router, but there the docs point you to app/ instead. Pick one location, never both.
The trap: public/robots.txt and app/robots.ts together
This often happens after a migration: the old public/robots.txt stays in place and someone adds app/robots.ts. We built it both ways on 16.4.6:
| Setup, 27 Nov 2026 | next build | next start serves | next dev serves |
|---|---|---|---|
app/robots.ts only | passes, ○ /robots.txt | the generated file, 23 lines | the generated file |
app/robots.ts and public/robots.txt | passes, no warning | the public file; your robots.ts rules are gone | 500, "A conflicting public file and page file was found for path /robots.txt" |
So the production build hides the problem. The rules you wrote in robots.ts never ship, and only the dev server tells you, with a 500 and a link to the conflicting public file page message. To check your project: ls public/robots.txt app/robots.* 2>/dev/null. If it prints more than one file, delete the one you are not maintaining, then rebuild.
The trap: proxy.ts redirects robots.txt to your login page
Next.js 16 renamed middleware.ts to proxy.ts. A typical sign-in gate redirects every path without a session cookie, and the usual matcher only leaves out _next/static, _next/image and favicon.ico. We built that gate with the starter robots.ts in place:
$ curl -sI http://localhost:3000/robots.txt
HTTP/1.1 307 Temporary Redirect
location: /login
A crawler that follows the redirect gets an HTML page, not your rules. The same thing happens to an MCP server card behind the same gate. The fix is one more exclusion in the matcher. The proxy docs' own examples leave out sitemap.xml and robots.txt:
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico|robots.txt|sitemap.xml).*)'],
}
After that change, the same request returned 200 and content-type: text/plain.
Check it from outside
Fetch /robots.txt from your production domain, not localhost. curl -sI should show a 200 and text/plain with no location: header, and curl -s … | grep -c User-Agent should count your named groups. Then run the scan in the next section. A file that is right but a site that still looks empty to an AI crawler is a rendering problem, not a robots problem: see why Next.js and React sites can look empty to AI crawlers. Next.js also has a sitemap.ts convention for the URL in your Sitemap: line; the sitemap guide covers what to put in it. The token names are in the 2026 AI crawler user-agent list, and the other Next.js guides are on our Next.js platform page.
Verify it did what you meant
Start with a scan. Run npx aiscan-cli yoursite.com, or paste your URL at aiscan.site. It is free and needs no account. Three checks apply here:
- B1, Content Signals: whether robots.txt declares AI usage preferences. Informational, it cannot lower your score.
- B2, explicit AI bot rules: whether the AI crawlers have their own named groups. Four or more named bots passes, one to three is partial.
- B3, Web Bot Auth: a signing key directory for bots you operate. Most site owners publish nothing here.
The scan reads what you publish. It cannot see your server logs or whether the server refuses a bot, which is why the hand checks below still matter. Details for each check are on the bot access checks page.
If you would rather check by hand:
curl -sI https://yoursite.com/robots.txt | head -3 # expect 200 and text/plain
curl -s https://yoursite.com/robots.txt | grep -ciE 'gptbot|claudebot|oai-searchbot'
python3 -c "
from urllib.robotparser import RobotFileParser as R
r=R(); r.set_url('https://yoursite.com/robots.txt'); r.read()
for ua in ['GPTBot','ClaudeBot','OAI-SearchBot','PerplexityBot','Googlebot']:
print(ua, r.can_fetch(ua,'https://yoursite.com/'), r.can_fetch(ua,'https://yoursite.com/admin/x'))
"
Against the starter file above, that check prints False False for GPTBot and ClaudeBot, True False for OAI-SearchBot, PerplexityBot and Googlebot. We ran it on 7 October 2026. The expected result for your site is the same pattern. Python's parser applies first-match rules rather than the longest-match rule in RFC 9309, so use it for group logic, not for complicated Allow and Disallow overlaps.
To test enforcement rather than the file, request a page with the bot's user-agent string and compare it to a browser request, as shown in Fetch your site the way an AI agent sees it. A spoofed string proves the server rule, not the real crawler, so check real traffic against the operator's published IP ranges.
Two variants of the starter
Open to everything. Write nothing. An absent or empty robots.txt means crawl freely. The trap is a robots.txt URL that returns a 500 or an HTML soft-404 page, which some crawlers treat as a signal to stay away. Make sure the URL returns a real 200 with plain text, even if the file only holds a Sitemap: line.
Closed to AI, open to search. Take the starter and move the search and live-fetch tokens into the Disallow: / group: OAI-SearchBot, Claude-SearchBot, PerplexityBot, Amzn-SearchBot, MistralAI-Index, plus ChatGPT-User, Claude-User, Perplexity-User, Amzn-User and MistralAI-User. Leave Googlebot and bingbot alone. Expect to disappear from AI answers, and treat that as a decision you made on purpose. For the argument about whether this is worth it, read the training-opt-out evidence rather than this guide.
When a rule does not seem to work
- "GPTBot is still in my logs after I blocked it." Wait 24 hours for OpenAI to pick up the change, then check the source IP against the ranges OpenAI publishes. A request that only claims to be
GPTBotcan be anyone. - "My named group ignores my
*rules." That is the specificity rule working as designed. Repeat theDisallowlines inside the named group. - "A bot I blocked still fetches pages when I ask an assistant about them." User-triggered fetchers such as
Perplexity-Usergenerally ignore robots.txt, andChatGPT-Useracts on a person's request. Use a firewall rule if you need those refused. - "The scan says B2 is partial." B2 counts named groups. Fewer than four named AI bots gives partial credit, so add the missing groups from the starter.
- "The scan cannot find my robots.txt." Open the URL in a browser. A redirect to a login page or an HTML error page means crawlers see no valid file.
Maintenance
- Re-check the token list every quarter. Operators add bots: Amazon, Mistral and Meta all now split training, search and live fetch.
- After any theme change, plugin install or migration, re-run the scan. Platform editors overwrite robots.txt more often than you would expect.
- Keep the private paths in sync. Whenever you edit the
*group, update every named group that repeats it. - Do not use
Disallowto hide a secret path. RFC 9309 notes that listing paths in robots.txt exposes them publicly.
If your site is behind Cloudflare, you can also enforce these preferences at the edge. Cloudflare AI Crawl Control shows how to allow or block each crawler and how its managed robots.txt joins your file.
What to do next
Run npx aiscan-cli yoursite.com and read B1 and B2. If B2 is partial, paste the starter, redeploy and scan again. For the wider picture, browse the AI readiness guides, and read the sitemap guide next, because the Sitemap: line sits in the same file.
If the file you serve blocks everything and you never meant it to, see Your robots.txt blocks everything by accident for how to find the stray Disallow: / and guard against it.
If a Python script reports your whole site as blocked while the file looks fine, the cause may be a 403 on robots.txt that Python's parser reads as disallow-all: see Python's robots.txt parser treats a 403 as disallow-all.
Related: on a Cloudflare zone, robots.txt is only half the story. What Cloudflare's 15 September 2026 change did to Googlebot explains Block versus Disallow AI Training and how to test the edge with curl.
Frequently asked questions
Which AI crawlers should I block in robots.txt?
It depends on the job. Training crawlers such as GPTBot, ClaudeBot, CCBot, Google-Extended and Applebot-Extended collect content for model training. Search crawlers such as OAI-SearchBot and PerplexityBot decide whether you appear in answers. Most publishers block the first group and allow the second.
Does blocking GPTBot remove me from ChatGPT search?
No. OpenAI documents that each setting is independent, so you can disallow GPTBot while allowing OAI-SearchBot to appear in ChatGPT search answers. Blocking OAI-SearchBot is what removes you from those results.
What is the difference between GPTBot, OAI-SearchBot and ChatGPT-User?
GPTBot collects content that may be used for training. OAI-SearchBot builds the search index. ChatGPT-User visits a page when a person asks ChatGPT or a custom GPT about it. Anthropic splits ClaudeBot, Claude-SearchBot and Claude-User the same way.
Is robots.txt enough to stop AI companies using my content?
No. RFC 9309 says the protocol is not a substitute for content security. It is a request. In AIScan's measurement of 40 hosts, a full Disallow was backed by an edge refusal only 45% to 67% of the time. Use your CDN or firewall to enforce it.
I blocked GPTBot but it still appears in my access logs. What is wrong?
Wait about 24 hours, because OpenAI says its systems take that long to pick up a change. Then compare the request IP with the ranges OpenAI publishes. A request that only claims to be GPTBot in its user-agent string can come from anyone.
My named bot group ignores the rules in my * group. Why?
A bot follows the most specific group that names it, and then ignores the * group entirely. This is how RFC 9309 works. Repeat the Disallow lines from the * group inside each named group.
The scan says B2 is partial. How do I fix it?
B2 counts explicit User-agent groups for known AI crawlers. Four or more passes and one to three gives partial credit. Add named groups for the AI bots, whether you allow or disallow them, then redeploy and rescan.
Why does Perplexity-User still fetch my pages after I disallowed it?
Perplexity documents that Perplexity-User generally ignores robots.txt because a person triggers the request. Other user-triggered fetchers behave in similar ways. If you need those requests refused, add a firewall or CDN rule.
Where exactly does robots.txt go in a Docusaurus project?
At static/robots.txt, in the project root next to docusaurus.config.js. Docusaurus copies every file in that folder into the root of the build output with the directory hierarchy preserved, so the file needs no front matter, no extension change and no registration anywhere.
I moved my docs to GitHub Pages and my crawler rules stopped being obeyed. What changed?
A GitHub Pages project site is served under a repository path, which forces baseUrl to /<project>/. RFC 9309 requires the rules at the top-level path of the service, so a file one directory down is not read at all. Nothing about your file changed; its URL did.
Can I keep robots.txt somewhere other than static/?
Yes. The staticDirectories option in docusaurus.config.js accepts a list of source folders, so setting staticDirectories: ['public', 'static'] lets you keep the file in public/ instead. The copy behaviour and the resulting URL are identical either way.
I saved my GPTBot rule but it is not in the file. What went wrong?
The save is two clicks, not one. In the Robots.txt Editor you click Save Changes and then Save; stopping after the first leaves the edit uncommitted. Reopen SEO & GEO > Tools and settings > Robots.txt Editor > View File and check the text is actually there before fetching the file again. Search engines also cache robots.txt, so your own curl will show the change before a crawler sees it.
Google Search Console says Blocked by robots.txt on a page I never named. Why?
Wix's own guidance is that this is usually not a robots.txt problem at all: "you don't need to edit your robots.txt file, especially if you never edited it before." Check whether indexing is switched off for that page in your site's editor or SEO Settings, and whether the page is password protected or members only. Editing robots.txt to fix it will not help and can make things worse.
I added deny rules and my pages fell out of Google. How do I undo it?
Go to SEO & GEO > Tools and settings > Robots.txt Editor > View File, click Reset to Default, then Reset. That restores the file Wix generates. Recovery is not instant: search engines refresh their cached copy of robots.txt on their next crawl, and Wix suggests submitting your homepage for reindexing if you need it sooner.
Will editing robots.txt stop Wix maintaining it, the way editing llms.txt does?
No, and this is the useful difference between the two files on Wix. Wix documents that llms.txt "will stop updating automatically" once you edit it. For robots.txt it says the opposite: "Wix automatically updates your robots.txt after you publish the page", and settings changes update the file immediately. Your named crawler groups sit alongside a * group Wix keeps regenerating.
I added AI crawler rules in Rank Math but my robots.txt has not changed. Why?
There is almost certainly a physical robots.txt in your web root. The web server sends that file before WordPress runs, so Rank Math's virtual file is never served. Rank Math's own guide says to delete the physical file first. Keep a copy, delete it, purge your cache and fetch /robots.txt again.
My WordPress robots.txt shows up as one long line. Is that a problem?
Yes. If the file starts with a # comment and every line break has become a space, crawlers read the whole file as one comment and no rule applies. A page cache or HTML minifier usually does this. Exclude /robots.txt from page caching and minification, purge, and check that curl -s https://yoursite.com/robots.txt | wc -l shows more than one line.
Yoast's File editor menu is missing. How do I edit robots.txt?
Yoast hides the File editor when WordPress file editing is disabled, for example with DISALLOW_FILE_EDIT in wp-config.php. Edit or upload robots.txt in the web root over SFTP or your host's file manager, or add the rules with a robots_txt filter in a must-use plugin while no physical file exists.
I added app/robots.ts in Next.js but my live robots.txt still shows the old rules. Why?
There is probably still a robots.txt in public/. We built both on Next.js 16.4.6: next build passed with no warning and next start served the public file, so the rules in robots.ts never shipped. Only next dev reports it, with a 500 and the message 'A conflicting public file and page file was found for path /robots.txt'. Delete one of the two files and rebuild.
My Next.js robots.txt returns a 307 redirect to /login. How do I fix it?
Your proxy.ts (middleware.ts before Next.js 16) is catching the request. Add robots.txt and sitemap.xml to the negative lookahead in its matcher, for example '/((?!_next/static|_next/image|favicon.ico|robots.txt|sitemap.xml).*)', then redeploy and check that curl -sI shows a 200 with text/plain and no location header.
Next.js printed my user agents as one group, not separate groups like the docs show. Is that wrong?
No. On Next.js 16.4.6 a userAgent array came out as stacked User-Agent lines above one set of rules, while the docs' sample output shows one group per agent. RFC 9309 allows both and a crawler reads them the same way. Check the result with the scan or Python's robotparser rather than by comparing text.

About the author
M Asif Rahman
Entrepreneur, curious about AI
I have been building companies for a long time, and lately most of my curiosity goes to AI. AIScan is a small personal project I built on a flight from Dubai to Narita. I use it to understand how ready the web is for AI agents, and I share what the scans teach me.
Related guides
AI readiness setup guide by platform (2026)
Verified 17, 18, 20 and 22 October 2026. Updated on 22 October 2026. An AIready site needs six things: a robots.txt that names AI crawlers D1, B2, a sitemap D2, a declared feed E5, an llms.txt C2,…
llms.txt vs robots.txt vs sitemap.xml: Six Files, 843 Sites
Updated on 15 November 2026. The study below was measured on 4 September 2026; a rerun on 843 sites, scanned up to 15 November, is in its own section, and the live examples were rechecked the same…
Declare your content-use policy to AI: Content Signals, ai.txt, TDMRep
Blocking or allowing a crawler answers one question: may it fetch this page. It says nothing about what the crawler may do afterwards. This guide covers the three places a site can state that second…
