CraftTools

Robots.txt Generator

Guide: How to Write a robots.txt File (With Examples)

Rule 1

Save this as robots.txt in the root folder of your site, so it loads at yourdomain.com/robots.txt.

Nothing you enter or choose here leaves your device. This tool runs in your browser.

What a robots.txt file does

A robots.txt file is a plain text file at the root of your site that tells crawlers which URLs they may request. Search engines, AI scrapers and SEO tools read it before they crawl, and the polite ones follow it. It's a request, not a lock. A badly behaved bot can ignore it, so never rely on it to protect anything private.

The file is made of groups. Each group starts with a User-agent line that names a crawler, followed by Disallow and Allow lines with URL paths. A Sitemap line can go anywhere in the file and points to your sitemap by its full address.

Three setups you can copy

A WordPress blog usually wants to keep crawlers out of the admin area, but the admin-ajax file has to stay reachable because some themes and plugins load content through it:

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

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

An online shop has a different problem. Sort and filter options create thousands of near-identical URLs, and cart and checkout pages are useless in search. Blocking them saves crawl time for the pages that sell:

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

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

A staging site should be closed to everything. One line does it, though a password on the staging server is the safer fix, because robots.txt only asks nicely:

User-agent: *
Disallow: /

How a crawler picks a rule

When more than one rule matches a URL, Google follows the most specific one, meaning the one with the longest path. That's why the blog example works: /wp-admin/admin-ajax.php is longer than /wp-admin/, so the Allow line wins for that one file. If two rules match with the same length, Allow wins.

Two pattern characters are supported by Google and Bing. A star matches any run of characters, and a dollar sign marks the end of the URL. So Disallow: /*.pdf$ blocks every URL that ends in .pdf. Paths are case-sensitive, which means /Admin/ and /admin/ are different folders.

A crawler that has its own named group only follows that group. If you add a Googlebot group, Googlebot stops reading the * group completely, so copy any rules you still want into it.

Mistakes that cost real traffic

  • Shipping the staging file to production. A single Disallow: / that makes it to the live site can drop your pages out of search within weeks. Open yourdomain.com/robots.txt after every deploy.
  • Blocking CSS and JavaScript folders. Google renders pages the way a browser does. If it can't load your styles, it may misjudge the layout and the mobile experience.
  • Using it to hide a page from results. A blocked URL can still be indexed if other sites link to it, and it shows up with no description. Worse, because the crawler never fetches the page, it never sees a noindex tag on it. To keep a page out of results, let it be crawled and add a noindex tag (the meta tag generator can help), or put it behind a login.
  • Expecting Crawl-delay to slow Google down. Google ignores that line. Bing and a few other crawlers honor it.
  • Putting the file in the wrong place. It has to load from the root of the exact host. A file at /files/robots.txt is never read, and blog.example.com needs its own copy separate from example.com.
  • Misreading an empty Disallow. A line that says only Disallow: blocks nothing. It means everything is allowed, which is the opposite of what a quick glance suggests.

Blocking AI crawlers

Most AI companies publish a crawler name you can target. OpenAI's is GPTBot and Common Crawl's is CCBot. To block one, add its own group:

User-agent: GPTBot
Disallow: /

User-agent: CCBot
Disallow: /

Google uses a separate token, Google-Extended, to decide whether your content can be used for its AI models. Blocking it doesn't change how you rank in Google Search. All of this only works on crawlers that choose to obey the file.

Check it before you walk away

After uploading, load /robots.txt in a browser. You should see plain text and a normal page load, not a 404 or an HTML page. Google Search Console has a robots.txt report that shows when it last fetched the file and whether it found errors. Keep the file under 500 KB, since Google stops reading past that point. For a longer walkthrough of the syntax, see the robots.txt guide.

Written by Akinrinmade Michael · Updated October 24, 2026

How to use

  1. 1Choose a crawler and list the paths to block or allow.
  2. 2Add your sitemap address.
  3. 3Copy the file to your site's root folder.

Frequently asked questions

Where does robots.txt go?

In the root folder, so it loads at yourdomain.com/robots.txt.

Does it hide pages from search?

No. It asks well-behaved crawlers not to visit. Use a noindex tag to keep a page out of results.

How do I block AI crawlers?

Add a rule for the crawler, such as GPTBot or CCBot, and block /.

What does * mean?

It means every crawler.

Is my data uploaded?

No. Everything runs in your browser, so what you paste never leaves your device.

Do I need a robots.txt file at all?

No. If the file is missing, crawlers assume they can visit everything. A plain 404 is fine. A server error is worse, because Google may pause crawling until the file loads again.

Why is Google still showing a page I blocked?

Blocking stops the crawl, not the listing. If other sites link to the page, Google can list the bare URL without a description. To remove it, allow crawling and add a noindex tag, or put the page behind a login.

Read the guide

Learn how this works and how to get the most from it.

Web & SEO

How to Write a robots.txt File (With Examples)

What robots.txt does and doesn't do, how Disallow and Allow rules work, how to add your sitemap, and mistakes that can hide your whole site.

3 min read

Meta Tag Generator

Generate SEO, Open Graph and Twitter Card meta tags with live previews.

.htaccess Generator

Redirects, HTTPS, caching and more for Apache sites.

UTM Link Builder

Add campaign tracking to any link.

URL Parser & Query Builder

Split a URL into its parts and edit its query parameters.