Skip to content
Mikoshi SEO Mikoshi SEO

robots.txt Examples: 8 Templates to Copy, Including AI Crawlers

BY DZAN VOLODER, FOUNDERLAST UPDATED 6 MIN READ

A set of robots.txt templates side by side: allow all, block a folder, and allow AI search while blocking AI training
THE SHORT ANSWER

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. [1]Google Search Central: How to write and submit a robots.txt file
  2. [2]Google Search Central: How Google interprets the robots.txt specification

1. Allow everything

The right default for most marketing sites. An empty Disallow line does the same job, but Allow: / is easier to read.

ROBOTS.TXT // ALLOW ALL
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.

ROBOTS.TXT // BLOCK ALL
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.

ROBOTS.TXT // BLOCK A 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.

ROBOTS.TXT // BLOCK PDF FILES
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.

ROBOTS.TXT // FILTERS AND INTERNAL SEARCH
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.

ROBOTS.TXT // WORDPRESS
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.

ROBOTS.TXT // AI SEARCH YES, AI TRAINING NO
# 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
  1. [3]OpenAI: Overview of OpenAI crawlers
  2. [4]Anthropic: How site owners can block Anthropic's crawler
  3. [5]Perplexity: Perplexity crawlers
  4. [6]Google: Google's common crawlers, including Google-Extended
  5. [7]Apple Support: About Applebot and Applebot-Extended
  6. [8]Common Crawl: CCBot

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.

ROBOTS.TXT // BLOCK AI CRAWLERS
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: /
  1. [3]OpenAI: Overview of OpenAI crawlers
  2. [5]Perplexity: Perplexity crawlers

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.
  1. [9]Google Search Central: Introduction to robots.txt
  2. [10]Google Search Central Blog: A note on unsupported rules in robots.txt, July 2019

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.

  1. [11]Search Console Help: robots.txt report

FAQ

For most sites, allow everything, block only low-value URL patterns such as internal search and filters, and include a Sitemap line. Fewer rules means fewer mistakes.

FREE // AI VISIBILITY SNAPSHOT

See who AI recommends instead of you.

Free snapshot within 2 business days.