Free, independent guides since 2010

SEO

Robots.txt: a practical guide with examples

What robots.txt does and does not do, its syntax with practical examples, blocking AI crawlers, common mistakes that block whole sites, and how to test your file.

<guide section="SEO" type="article" read="1 min"/>

The robots.txt file in the root of your site is one of the oldest web standards. It is simple, powerful and frequently misunderstood. Ours is three lines long – most small sites need little more.

The basics

Plain text
User-agent: *
Disallow: /admin/
Disallow: /search

Sitemap: https://www.example.com/sitemap.xml
  • User-agent: which crawler the rules apply to (* = all).
  • Disallow: paths not to crawl. Allow makes exceptions.
  • Sitemap: where your XML sitemap is.

Useful examples

Plain text
# Allow everything (an empty Disallow means nothing is blocked)
User-agent: *
Disallow:

# WordPress: block admin but allow the AJAX endpoint
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php

# Block an AI training crawler, allow everything else
User-agent: GPTBot
Disallow: /

User-agent: Google-Extended
Disallow: /

Blocking Google-Extended opts out of some Google AI uses without affecting Google Search. See SEO in the age of AI search.

Mistakes that cost traffic

MistakeEffect
Disallow: / left over from a test siteEntire site not crawled
Blocking CSS and JavaScriptSearch engines cannot render pages properly
Blocking pages you want removedNoindex tag never seen
Typos in paths, wrong caseRules do not match

Testing

Search Console shows the robots.txt file Google fetched and any problems. After changes, inspect a few important URLs to confirm they are crawlable. See also the technical SEO checklist.

Frequently asked questions

Does blocking a page in robots.txt remove it from Google?

No. A blocked page can still appear in results if other sites link to it, just without a description. To keep a page out of results, allow crawling and use a noindex tag.

Is robots.txt a security measure?

No. It is a public file that well-behaved crawlers respect. Never use it to hide sensitive content; protect that with authentication.