Examples are starting points, not files to copy blindly. Every rule below assumes a standard setup; adapt the paths to your own URLs and test the result before deploying. A rule that blocks the wrong path produces no error message anywhere — the page simply disappears from search results weeks later, and nothing connects the two events.
1. The minimal file: allow everything, announce the sitemap
Most small sites need nothing more than this:
User-agent: * Disallow: Sitemap: https://example.com/sitemap.xml
An empty Disallow means nothing is blocked. The Sitemap line tells crawlers where the list of URLs lives. If your site has no sections worth hiding, stop here — a longer file adds risk without benefit.
2. A personal blog
Block the admin area and internal search results, which are thin pages that waste crawl budget:
User-agent: * Disallow: /wp-admin/ Disallow: /?s= Disallow: /search/ Allow: /wp-admin/admin-ajax.php Sitemap: https://example.com/sitemap.xml
/?s= is the WordPress search URL; /search/ covers other platforms. The Allow for admin-ajax.php matters: themes use that file for front-end features, and blocking it breaks things visitors can see. The mistakes guide covers the failure mode in detail.
3. WordPress, the standard preset
User-agent: * Disallow: /wp-admin/ Disallow: /wp-login.php Disallow: /wp-includes/ Allow: /wp-admin/admin-ajax.php Sitemap: https://example.com/sitemap.xml
/wp-includes/ holds core files no visitor ever needs to crawl. Do not block /wp-content/ wholesale: themes and uploads live there, and blocking it hides your images and stylesheets from Google, which then judges your pages as broken.
4. An online shop
Block the pages that exist for the checkout flow, not for search:
User-agent: * Disallow: /cart/ Disallow: /checkout/ Disallow: /account/ Disallow: /*?sort= Disallow: /*?filter= Sitemap: https://example.com/sitemap.xml
Cart, checkout and account pages are near-duplicates with no search value. The sort and filter parameters create unlimited near-identical URLs; blocking the parameter pattern keeps the crawler on the canonical product and category pages. Note the wildcard: /*?sort= matches any URL containing ?sort=.
5. A staging site
User-agent: * Disallow: /
That is the whole file. But read the warning first: robots.txt is a request, not a lock. Any crawler that ignores the file will still index staging, and several do. Put password authentication in front of staging and treat the disallow as a second layer, not the protection itself.
6. Blocking AI crawlers
To keep AI training crawlers out while leaving search crawlers alone, name them explicitly:
User-agent: GPTBot Disallow: / User-agent: CCBot Disallow: / User-agent: anthropic-ai Disallow: / User-agent: Google-Extended Disallow: /
Each group applies to one crawler. Blocking Google-Extended controls whether Google uses your pages for AI training; it does not affect normal Google Search crawling, which runs as Googlebot. The list of AI crawler tokens changes as new companies appear, so check the current tokens before relying on this and re-check yearly.
How to adapt an example without breaking anything
Three steps. First, replace the example paths with your real ones — a rule for /wp-admin/ does nothing on a site that has no such path, and a rule for /cart/ does nothing if your cart lives at /basket/. Second, paste the file into the tester with five URLs: your homepage, a category page, a deep article, one asset from your stylesheet directory, and a URL you believe is blocked. Third, deploy and re-check in Search Console after a day to confirm Google fetched the new file.
Remember the one matching rule that governs everything: the longest matching rule wins. If an Allow and a Disallow both match a URL, the longer path governs, regardless of the order the lines appear in. When a test verdict surprises you, print both rules and count the characters — the longer one is the answer.