Skip to content
Koit Academy

Websites & SEO

·

7 min read

Robots.txt Examples: Seven Files for Common Sites

Seven robots.txt files to adapt - open site, blog, shop, staging, one blocked crawler, a private folder and a resource exception - every line explained.

By Koit Academy

Most robots.txt files are copied from somewhere else, and most problems with them come from copying the wrong one. A file written for a large shop blocks pages a small site needs; a file from a staging server blocks the whole live site. The right file is usually short, and it depends on what kind of site you run.

This post gives seven example files for common situations, explains every line, and ends with the checks to run before any of them goes live.

The rules every example follows

Each file is a set of groups. A group starts with one or more user-agent lines naming the crawlers it applies to, followed by allow and disallow rules for paths. Google reads only four kinds of line: user-agent, allow, disallow and sitemap. Anything else, such as crawl-delay, is ignored by Google.

Paths are matched from the start of the address, and they are case sensitive. An asterisk matches any run of characters and a dollar sign marks the end of the address; the details are in robots.txt wildcards. When two rules match the same address, Google follows the most specific one, the longest, and prefers allow when they are equally long.

1. A site with nothing to hide

User-agent: *
Disallow:

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

An empty disallow means nothing is blocked. For many small sites, a brochure site, a portfolio or a local business, this is the right file. The sitemap line tells crawlers where to find the list of pages. Having no robots.txt at all has the same effect on crawling, but the file is a convenient place for the sitemap line.

2. A blog

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

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

Internal search results create a new address for every query and offer nothing a search engine should index, so they are blocked. Everything else, posts, categories and pages, stays crawlable. Check which address your blog actually uses for search before copying; the two lines here cover the common patterns.

3. An online shop

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

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

Cart, checkout and account pages are private to each visitor and useless in search. Sort parameters create endless reorderings of the same category pages. Product and category pages are untouched, because nothing matches them. Shops with filter parameters have more to consider, covered in robots.txt for ecommerce.

4. A staging or development site

User-agent: *
Disallow: /

This blocks every compliant crawler from the whole site. It is the one file that must never be copied to the live site, and it is not a security measure: blocked addresses can still be listed in results if other sites link to them, and anyone can read the content. A staging site should sit behind a password as well.

5. Blocking one crawler, allowing the rest

User-agent: ExampleBot
Disallow: /

User-agent: *
Disallow:

A crawler follows the group that names it most specifically, so ExampleBot obeys the first group and every other crawler the second. Replace ExampleBot with the user-agent token the crawler’s operator publishes; tokens are not case sensitive, but they must be the documented name. Only crawlers that respect robots.txt will follow it.

6. A private folder with one public exception

User-agent: *
Disallow: /private/
Allow: /private/press-kit/

The allow rule is longer than the disallow, so it wins for the press-kit folder and everything inside it, while the rest of the private folder stays blocked. The order of the lines does not matter to Google; the length does.

7. Allowing a resource inside a blocked folder

User-agent: *
Disallow: /app/
Allow: /app/assets/

Some sites keep scripts and styles inside a folder that is otherwise blocked. Search engines need those files to render pages properly, so they should stay crawlable. Blocking the resources a page depends on can make it look broken to the crawler, even when it looks fine in a browser.

Where the file lives and how it is read

Robots.txt only works at the root of a host, at /robots.txt directly under the domain. A file in a folder is ignored. Each host and protocol has its own file, so a shop on shop.example.com needs its own if it runs on a subdomain, and a site that still answers on plain HTTP has a separate one there.

Google reads only the first 500 kibibytes of the file, so very long files lose their tail. A well written file for a small site is a few lines long, far below that. If a file has grown to hundreds of lines, many of them are probably redundant, contradictory or left over from a previous platform.

Comments and readability

Lines starting with # are comments, and crawlers ignore them. Use them. A short note above each group explaining why it exists, such as ”# internal search: endless addresses, nothing to index”, saves the next person from removing a rule they do not understand, or from leaving one that no longer has a purpose.

# Internal search: endless addresses, nothing to index
User-agent: *
Disallow: /search

When the file cannot be fetched

If robots.txt returns an error, crawlers have to decide what to do. Google’s documentation describes how it handles different responses: a missing file is treated as having no restrictions, while server errors can make Google treat the whole site as temporarily disallowed. A robots.txt that keeps returning server errors can therefore stop crawling altogether, so check that the file loads quickly and reliably after any server change.

What robots.txt cannot do

Every example above controls crawling, not indexing. A blocked address can still appear in results, without a description, if other pages link to it. To keep a page out of results, it must stay crawlable and carry a noindex instruction instead. And robots.txt is advice to well-behaved crawlers, not a lock: it keeps nothing private.

Adapting an example to your site

Start from the example closest to your site and change as little as possible. The robots.txt generator builds a file from the areas you want blocked, using only the lines Google reads, and adds the sitemap line. The sitemap it points to should list only pages you want found; the XML sitemap generator builds one from a list of addresses.

Blocking AI and other crawlers

Many site owners now want to decide which automated crawlers may use their content, including those that collect text for AI models. Robots.txt handles this in the same way as any other crawler: a group naming the crawler’s published user-agent token, with a disallow rule. Each company publishes the token its crawler obeys, and some use separate tokens for search and for model training, so check the operator’s own documentation for the exact name before adding it. Remember that robots.txt only works for crawlers that choose to follow it.

One file per host

A site that runs on several hosts, such as www.example.com for the main site and shop.example.com for the store, needs a robots.txt on each, written for the paths that host actually uses. A rule in the main site’s file has no effect on the shop. When a new subdomain is created, add its robots.txt and its sitemap at the same time, rather than discovering later that it was crawled without either.

Test before it goes live

A robots.txt mistake does not produce an error. The site keeps working, and crawlers quietly stop visiting pages. Before publishing a new file:

  1. List the addresses that must stay crawlable: the home page, key service or product pages, categories and articles.
  2. List the addresses that should be blocked: a cart page, a search result, a sorted category.
  3. Test both lists against the file. The robots.txt tester shows for each address whether it is allowed or blocked, for which crawler, and which rule decided it.
  4. Check the live file after publishing, at the root of the site, to make sure the server returns the new version.

Keep a copy of every version

Robots.txt changes are easy to make and easy to forget. Keep each version of the file, with the date and the reason for the change, in the same place as the rest of the site’s code or in a shared document. When search traffic drops and someone asks whether robots.txt changed, the answer should take a minute to find, not an afternoon. It also makes undoing a bad change a matter of restoring the previous version.

Common mistakes in copied files

  • A disallow for the whole site, carried over from staging.
  • Rules for a different platform, blocking paths your site does not use and missing the ones it does.
  • A short prefix that blocks too much, such as /p, which matches every address starting with p.
  • Crawl-delay lines, which Google ignores.
  • Blocking scripts and styles that pages need to render.

Sources, read November 14, 2026:

  • Google Search Central, How Google interprets the robots.txt specification: the supported fields, matching from the start of the path, case-sensitive paths, the * and $ wildcards, the longest-rule and least-restrictive precedence, and the most specific group per crawler.