What is a robots.txt file?
A robots.txt file is a plain text file at the root of your site that tells crawlers which URLs they may fetch. Search engines like Googlebot and Bingbot read it before they crawl, and so do most AI crawlers such as GPTBot and ClaudeBot.
Use it to keep crawlers out of admin areas, cart and checkout pages, internal search results and endless filter URLs, so they spend their crawl budget on pages that matter. It is a set of requests, not a lock: well-behaved bots follow it, bad bots ignore it, and anyone can read the file.
Robots.txt syntax: User-agent, Disallow, Allow and Sitemap
A robots.txt file is made of groups. Each group starts with one or more User-agent lines and lists the rules for those crawlers. A crawler follows only the most specific group that names it, and falls back to User-agent: *.
| Directive | What it does | Example |
|---|---|---|
User-agent | Names the crawler the group applies to; * means all crawlers | User-agent: Googlebot |
Disallow | Asks the crawler not to fetch paths that start with this value | Disallow: /admin/ |
Allow | Lets the crawler fetch a path inside a blocked folder | Allow: /admin/help/ |
Sitemap | Gives the full URL of your XML sitemap; can go anywhere in the file | Sitemap: https://www.example.com/sitemap.xml |
Crawl-delay | Asks for a pause between requests; Google ignores it | Crawl-delay: 10 |
Paths are case-sensitive. * matches any run of characters and $ marks the end of the URL, so Disallow: /*.pdf$ blocks every PDF. An empty Disallow: allows everything, and Disallow: / blocks the whole site.
User-agent: *
Disallow: /admin/
Disallow: /cart
Disallow: /*?sort=
Allow: /admin/help/
Sitemap: https://www.example.com/sitemap.xmlHow to block AI crawlers like GPTBot and ClaudeBot
To keep your content out of AI model training, give each AI crawler its own group with Disallow: /. The generator's "Block AI training bots" preset does this for the crawlers below while leaving Googlebot and Bingbot open.
| User-agent | Company | What blocking it does |
|---|---|---|
GPTBot | OpenAI | Stops crawling for model training. ChatGPT search uses a different bot, OAI-SearchBot. |
ClaudeBot | Anthropic | Stops crawling for model training. |
Google-Extended | Stops use of your content for Gemini training and grounding. It does not affect Google Search. | |
Applebot-Extended | Apple | Stops use for Apple's AI training. Applebot still crawls for Siri and Spotlight. |
CCBot | Common Crawl | Stops the open web archive many AI models are trained on. |
PerplexityBot | Perplexity | Removes your pages from Perplexity's search index, so it can no longer cite them. |
Bytespider | ByteDance | Asks ByteDance's crawler to stay away; reports say it does not always obey. |
Blocking AI search crawlers (such as PerplexityBot or OAI-SearchBot) can stop AI answers from citing and linking to you. Block training bots if you want to protect your content, but think twice before blocking the bots that send visitors.
Robots.txt examples for WordPress, Shopify and Next.js
WordPress. Keep the admin area out of the crawl but leave admin-ajax.php open, as WordPress does by default. Do not block theme or plugin files: Google needs CSS and JavaScript to render your pages.
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://www.example.com/sitemap_index.xmlShopify. Shopify creates robots.txt for every store and blocks cart, checkout, account and admin pages for you. To add rules, edit the robots.txt.liquid template in your theme rather than uploading a file.
Next.js and headless sites. Put the file in public/robots.txt, or generate it from app/robots.ts. Block API routes, never /_next/, which holds your CSS and JavaScript.
User-agent: *
Disallow: /api/
Sitemap: https://www.example.com/sitemap.xmlRobots.txt vs noindex: blocking crawling is not blocking indexing
Disallow stops a crawler from fetching a page, but Google can still index the URL without its content if other pages link to it. It then shows up in results with no description.
To keep a page out of Google, let it be crawled and add <meta name="robots" content="noindex"> or an X-Robots-Tag: noindex header. If robots.txt blocks the page, Google never sees the noindex. For private content, use a password.
Where to put robots.txt and how to test it
- Save the file as
robots.txt, plain text in UTF-8. - Upload it to the root of your host, so it opens at
https://www.example.com/robots.txt. A file in a subfolder is ignored. - Open the URL in a browser to check it returns the file with a 200 status.
- In Google Search Console, open the robots.txt report to see the version Google fetched, and request a recrawl after big changes.
- Test important URLs with our robots.txt validator to see which rule allows or blocks them.

