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
User-agent: *
Disallow: /admin/
Disallow: /search
Sitemap: https://www.example.com/sitemap.xmlUser-agent: which crawler the rules apply to (*= all).Disallow: paths not to crawl.Allowmakes exceptions.Sitemap: where your XML sitemap is.
Useful examples
# 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
| Mistake | Effect |
|---|---|
Disallow: / left over from a test site | Entire site not crawled |
| Blocking CSS and JavaScript | Search engines cannot render pages properly |
| Blocking pages you want removed | Noindex tag never seen |
| Typos in paths, wrong case | Rules 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.