Website & SEO Guides

Robots.txt Examples for Common Websites (Copy and Paste)

ShareXFacebookLinkedIn
Three fanned file cards with different rule lines and open, closed, and half-open gates

These robots.txt examples cover the situations most sites run into: allowing everything, blocking a folder, blocking a single crawler, protecting a WordPress admin area, keeping internal search pages out of the crawl, and adding a sitemap. Copy the one that fits, replace the example paths and domain with your own, and test the result before you rely on it.

If you are new to the file, read how to create a robots.txt file first. To build a file without writing it by hand, use the Robots.txt Generator.

How to Read a robots.txt File

Every file is made of groups. A group starts with a User-agent line that names a crawler, followed by Disallow and Allow rules for it. A few things help when reading or editing one:

  • User-agent: * means all crawlers that do not have a more specific group.
  • Paths start with / and are case sensitive.
  • When rules conflict, the more specific rule wins.
  • A crawler follows the group that matches it most specifically, and the order of groups does not matter.
  • Lines beginning with # are comments.

Example 1: Allow All Crawlers

User-agent: *
Disallow:

An empty Disallow means nothing is blocked. This has the same effect as having no robots.txt file, but it makes your intent explicit. Add a Sitemap line below it if you have one.

Example 2: Block the Entire Site

User-agent: *
Disallow: /

This blocks all compliant crawlers from the whole site. Use it only on a staging or private development site. It is one of the most damaging mistakes if it ends up on a live site by accident, so check your robots.txt after every launch. Blocking crawling this way does not guarantee pages stay out of search results; see robots.txt vs. noindex.

Example 3: Block a Folder

User-agent: *
Disallow: /private/

This blocks every URL whose path begins with /private/. Include the trailing slash if you mean the folder, because Disallow: /private would also match a path like /private-offers.

Example 4: Block a Folder but Allow One File Inside It

User-agent: *
Disallow: /downloads/
Allow: /downloads/brochure.pdf

The more specific Allow rule wins for that one file, so it stays crawlable while the rest of the folder is blocked.

Example 5: Block One Crawler Only

User-agent: ExampleBot
Disallow: /

User-agent: *
Disallow:

The first group blocks a crawler named ExampleBot from the whole site. The second group lets every other crawler in. Replace ExampleBot with the exact user-agent token from the crawler’s documentation. Tokens for some AI and SEO crawlers are published by the companies that run them, and they change over time, so check the current name rather than copying one from an old post.

Example 6: A Safe File for WordPress

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

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

This mirrors the default WordPress rules. It keeps crawlers out of the admin area but leaves admin-ajax.php reachable, because themes and plugins use it for features on the public side of the site. Your sitemap address may differ if an SEO plugin provides its own; see how to add a sitemap to robots.txt.

Example 7: Keep Internal Search Pages Out of the Crawl

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

Internal search results can generate endless, low-value URLs. These rules block the two patterns WordPress commonly uses. Adjust them to match how your own search URLs look.

Example 8: Online Store Basics

User-agent: *
Disallow: /cart/
Disallow: /checkout/
Disallow: /account/

These pages are personal to each visitor and have no value in search. Match the paths to your platform, because they vary.

Example 9: Block a File Type

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

Google supports two wildcards in paths: * matches any sequence of characters, and $ marks the end of the URL. This rule blocks URLs that end in .pdf. Other crawlers may treat wildcards differently, so test before relying on it.

Example 10: Add a Sitemap

User-agent: *
Disallow:

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

The Sitemap value must be a full, absolute URL. You can list more than one, and the line is not tied to any particular user agent.

A Complete Example for a Small WordPress Site

# Rules for all crawlers
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /?s=
Disallow: /search/

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

Before You Use Any Example

  • Replace every placeholder. example.com and the sample paths are not yours.
  • Do not block CSS or JavaScript that Google needs to render your pages.
  • Test the file. Open yourdomain.com/robots.txt, and check the key pages in Google Search Console.
  • Keep the file small. Google ignores anything after 500 KiB.
  • Remember it is not private. The file is public, and it does not keep determined bots out.

Conclusion

Most sites need only a handful of lines: a general group, a few blocked paths, and a sitemap. Start from the closest example, edit it to match your own site structure, and test it. When a rule is not essential, leave it out.

Frequently Asked Questions (FAQ)

What does Disallow: / mean in robots.txt?

It blocks the named crawler from the entire site. Under User-agent: *, that blocks all compliant crawlers.

What does an empty Disallow mean?

An empty Disallow: blocks nothing, so everything may be crawled.

How do I block one folder in robots.txt?

Add a Disallow line with the folder path, for example Disallow: /private/, under the right User-agent group.

Can I use wildcards in robots.txt?

Google supports * to match any sequence of characters and $ to mark the end of a URL. Support in other crawlers varies, so test your rules.

Is the standard WordPress robots.txt enough?

For many small sites, yes. The default blocks the admin area, keeps admin-ajax.php reachable, and may include your sitemap. Add more rules only when you have a specific reason.

Scroll to Top