robots.txt Examples: 8 Templates to Copy, Including AI Crawlers
BY DZAN VOLODER, FOUNDERLAST UPDATED 6 MIN READ
The simplest valid robots.txt allows everything: "User-agent: *" followed by "Allow: /" and a Sitemap line. Every other template on this page builds on that: block a folder with Disallow, use * and $ to match patterns, and add named groups for crawlers such as GPTBot or OAI-SearchBot when you want different rules for AI training and AI search.
Before you copy anything
Put the file at the root of each host, for example https://example.com/robots.txt, as plain UTF-8 text. Each crawler follows only the group with its most specific user agent, the longest matching rule wins, and paths are case-sensitive. Test the result before and after you publish it.
1. Allow everything
The right default for most marketing sites. An empty Disallow line does the same job, but Allow: / is easier to read.
User-agent: *
Allow: /
Sitemap: https://example.com/sitemap.xml
2. Block everything, for staging only
Use this on a staging or test site, never in production. It stops well-behaved crawlers, but it does not keep the site private, so put staging behind a password as well.
User-agent: *
Disallow: /
The most expensive SEO mistake we see is this file surviving a launch. After every deploy, check that production does not serve it.
3. Block a folder, with one exception
The longer rule wins, so the Allow line opens one path inside a blocked folder.
User-agent: *
Disallow: /app/
Allow: /app/pricing
Sitemap: https://example.com/sitemap.xml
4. Block a file type
The dollar sign anchors the rule to the end of the URL, so only URLs ending in .pdf match.
User-agent: *
Disallow: /*.pdf$
5. Block filter and search URLs
Faceted navigation and internal search can create endless URL variations. Blocking them saves crawl time for the pages that matter.
User-agent: *
Disallow: /search
Disallow: /*?sort=
Disallow: /*&sort=
Disallow: /*?filter=
Sitemap: https://example.com/sitemap.xml
6. WordPress
Keep the admin area out, but leave admin-ajax.php open, because themes and plugins use it on public pages.
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://example.com/wp-sitemap.xml
7. Allow AI search, block AI training
For brands that want to be cited by ChatGPT search, Claude and Perplexity but keep content out of model training. The search crawlers keep full access; the training crawlers and tokens are disallowed. Googlebot stays allowed through the * group, so Google Search and AI Overviews are not affected.
# AI search crawlers: can cite you
User-agent: OAI-SearchBot
User-agent: Claude-SearchBot
User-agent: PerplexityBot
Allow: /
# AI training crawlers and tokens
User-agent: GPTBot
User-agent: ClaudeBot
User-agent: Google-Extended
User-agent: Applebot-Extended
User-agent: CCBot
Disallow: /
User-agent: *
Allow: /
Sitemap: https://example.com/sitemap.xml
8. Block all known AI crawlers
Possible, but think twice: it also removes you from AI search answers. Fetches a user starts, such as ChatGPT-User and Perplexity-User, may not apply robots.txt at all, according to OpenAI and Perplexity.
User-agent: GPTBot
User-agent: OAI-SearchBot
User-agent: ChatGPT-User
User-agent: ClaudeBot
User-agent: Claude-SearchBot
User-agent: Claude-User
User-agent: PerplexityBot
User-agent: Perplexity-User
User-agent: Google-Extended
User-agent: Applebot-Extended
User-agent: CCBot
Disallow: /
User-agent: *
Allow: /
Common mistakes
- Using robots.txt to hide a page from Google. A blocked URL can still be indexed from links; use noindex on a crawlable page.
- Adding a Googlebot or GPTBot group and forgetting that the bot then ignores every rule in the * group.
- Blocking CSS and JavaScript files Google needs to render your pages.
- Relying on crawl-delay or noindex lines. Google supports neither in robots.txt.
- Leaving out the Sitemap line, the easiest way to point every crawler at your pages.
Test before you publish
Check the live file in Search Console's robots.txt report, then run your domain through our free AI crawler checker. It applies the same matching rules for 18 AI crawlers and shows the exact line that allows or blocks each one.