Indexing and redirects

Robots.txt examples: templates you can copy

Copy-ready robots.txt files for the most common situations, with a plain-English explanation of every line. Use them as a starting point, or build your own with the generator on this page.

Every site's robots.txt should be small and specific. These examples cover the cases most sites need. Replace example.com with your domain, and always test a new file before you publish it.

1. Allow everything

The simplest valid robots.txt. Every crawler can visit every page.

User-agent: *
Disallow:

Sitemap: https://example.com/sitemap.xml

An empty Disallow: means nothing is blocked.

2. Block one folder

User-agent: *
Disallow: /admin/

Sitemap: https://example.com/sitemap.xml

3. Block a folder but allow one page inside it

User-agent: *
Disallow: /members/
Allow: /members/join/

The longer, more specific Allow rule wins for /members/join/.

4. WordPress

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php

Sitemap: https://example.com/wp-sitemap.xml

Keep admin-ajax.php open: some themes and plugins use it on the front end. Don't block /wp-content/ or /wp-includes/, which hold the CSS, JavaScript and images Google needs.

5. Online shop

User-agent: *
Disallow: /cart/
Disallow: /checkout/
Disallow: /account/
Disallow: /*?sort=
Disallow: /*?filter=

Sitemap: https://example.com/sitemap.xml

The wildcard rules stop crawlers wasting time on endless sorting and filter combinations. Make sure your category pages themselves stay crawlable. (Shopify generates its own robots.txt with similar rules; you can edit it with a robots.txt.liquid template.)

6. Block internal search results

User-agent: *
Disallow: /search
Disallow: /*?s=

7. Block a file type

User-agent: *
Disallow: /*.pdf$

$ means "ends with", so this blocks addresses ending in .pdf.

Build your own

Use the generator on this page to tick the sections you want to block, choose which AI crawlers to allow, add your sitemap and copy a ready file. Then keep reading for the special cases.

Free tool

Robots.txt Generator

Choose what to block, including AI training crawlers, and download a correct robots.txt. It's tested as you build it.

Free, no sign-up. Everything runs in your browser.

Open the full Robots.txt Generator page →

8. Staging or development site

User-agent: *
Disallow: /

This blocks everything, but it isn't protection: blocked pages can still be indexed from links. Put staging sites behind a password, and never copy this file to the live site.

User-agent: GPTBot
Disallow: /

User-agent: Google-Extended
Disallow: /

User-agent: CCBot
Disallow: /

User-agent: *
Disallow:

This blocks OpenAI's training crawler, Google's AI training control and Common Crawl, while leaving Googlebot and other search crawlers alone. See how to block AI crawlers for the full list of bots.

10. Block one crawler entirely

User-agent: BadBot
Disallow: /

Only works for bots that respect robots.txt. Use your server or CDN firewall for bots that don't.

11. Several sitemaps

User-agent: *
Disallow:

Sitemap: https://example.com/sitemap-pages.xml
Sitemap: https://example.com/sitemap-products.xml

12. Different rules for Googlebot

User-agent: Googlebot
Disallow: /drafts/

User-agent: *
Disallow: /drafts/
Disallow: /beta/

Googlebot follows only its own group, so repeat any shared rules there.

Mistakes to avoid

  • Blocking CSS, JavaScript or image folders.
  • Using robots.txt to hide private pages (it's public).
  • Using it to remove pages from Google (use noindex instead).
  • Writing Disallow: /p when you mean /private/.

Test any rule against a real address with the robots.txt tester.

Questions

What is a good default robots.txt?

Allow everything, block only admin, cart or account areas, and list your sitemap. Most sites need very few rules.

Should I block wp-admin in robots.txt?

Yes, but allow /wp-admin/admin-ajax.php. Don't block /wp-content/ or /wp-includes/, which Google needs to render pages.

Can robots.txt block AI crawlers?

Yes, for crawlers that respect it, such as GPTBot, ClaudeBot and CCBot. Add a User-agent group with Disallow: / for each one.

Where do I upload robots.txt?

To the root of your domain so it loads at https://yourdomain.com/robots.txt. Platforms like Shopify and WordPress may generate it for you.

See what to fix on your website today.

Free plan, no credit card. Your first fixes in about a minute.