Not sure what a robots.txt file should say, or whether it can hurt your rankings? A robots.txt file is a plain text file that tells crawlers which URLs they may fetch; it controls crawling, not indexing.
This guide covers one technical piece of website optimization: the small file that tells crawlers where they may go.
| Item | Value |
|---|---|
| Formal standard | RFC 9309, September 2022 |
| Protocol first defined | 1994 |
| File location | Top-level directory of the site |
| Redirect hops Google follows | At least five redirect hops |
| Google’s cache time for the file | Up to 24 hours |
| Google’s crawl pause after a server error | First 12 hours |
The figures come from RFC 9309 and Google’s robots.txt specification page. They can change, so check the sources before you rely on them.
What robots.txt does and does not do
A robots.txt file is a text file containing rules about which crawlers may access which parts of a site, as Google’s specification page describes it. Its main job is to tell search engine crawlers which URLs they can access on your site, according to Google’s introduction to the file.
The format goes back to the Robots Exclusion Protocol that Martijn Koster defined in 1994. It was later written up as a Standards Track document, RFC 9309, in September 2022.
Three limits matter before you write a single rule:
- It is not security. The RFC says plainly that these rules are not a form of access authorization (RFC 9309).
- It is voluntary. Googlebot and other respectable web crawlers obey the file, while other crawlers might not (Google’s introduction).
- It is not a delisting tool. A disallowed URL can still be found and indexed if it is linked from other places on the web, per the same Google guide.
Robots.txt syntax: groups, user-agents and rules
The RFC splits the file into two building blocks. A rule is a line with a key-value pair that defines how a crawler may access URIs, and a group is one or more user-agent lines followed by one or more rules (RFC 9309).
Each crawler sets its own name, called a product token, and uses it to find the groups that apply to it (RFC 9309). When a crawler reads your file, it works through these steps:
- It looks for a group matching its product token, using case-insensitive matching (RFC 9309).
- If several groups match, their rules are combined into one group (RFC Editor copy).
- If no group matches, it obeys the group whose user-agent value is “*”, when one exists (RFC 9309).
- If there is no matching group and no “*” group, no rules apply (RFC 9309).
One quirk is worth remembering: a file whose last group has no rules allows everything, according to the protocol definition.
Robots.txt examples you can adapt
These examples use only the directives the RFC defines: user-agent, allow and disallow. Swap the folder names for your own paths before you publish anything.
| Goal | Lines in the file |
|---|---|
| Keep every crawler out of one folder | User-agent: * Disallow: /includes/ |
| Let one crawler into that folder anyway | User-agent: * Disallow: /includes/ User-agent: Googlebot |
| Block one named bot from the whole site | User-agent: ExampleBot Disallow: / |
| Allow everything | User-agent: * |
The group-matching behaviour in these samples follows RFC 9309, and the layout mirrors the structure on Google’s specification page.
In the second row, Googlebot has a group that matches its own name, so the “*” group is not applied to it. Because matching is case-insensitive, a lowercase “googlebot” would reach the same group as “Googlebot”.
The third row uses the broadest possible path, a single slash, so double-check it before you save. If you publish a sitemap as well, the guide on how to create an xml sitemap shows how to build one.
Where the file lives and how Google reads it
You must place the file in the top-level directory of a site, on a supported protocol. The URL is case-sensitive, like other URLs (Google’s specification).
The rules apply only to the host, protocol and port number where the file is hosted, so one file does not cover every version of your site (Google’s specification).

The HTTP status code returned for the file changes what Google does with it:
- Success: status codes that signal success prompt Google’s crawlers to process the file as the server provided it.
- Redirects: Google follows at least five redirect hops, then stops and treats the file as a 404. It does not follow logical redirects such as frames, JavaScript or meta refresh.
- Client errors: all 4xx errors except 429 are treated as if a valid file did not exist.
- Server errors: for the first 12 hours Google stops crawling the site but keeps trying to fetch the file. After that it uses the last good version for the next 30 days while it keeps trying for a new one.
All of that comes from Google’s specification page, which also says Google generally caches the file for up to 24 hours. It may cache it longer when refreshing is not possible, for example because of timeouts or 5xx errors.
Common robots.txt mistakes
- Using it to hide pages. Google warns that a disallowed URL can still be indexed when other sites link to it, so use password protection or another method for anything private (Google’s introduction).
- Blocking resources Google needs. If missing resources make a page harder to understand, Google advises against blocking them, or it will not analyze pages that depend on them well (Google’s introduction).
- Putting the file in a folder. Crawlers do not check for robots.txt files in subdirectories (Google’s specification).
- Forgetting subdomains. A file on a subdomain is only valid for that subdomain (Google’s specification).
- Treating every crawler alike. Each crawler might interpret the rules differently, so test the bots you care about (Google’s introduction).
Blocking a page also stops crawlers from fetching it, so review your rules before you add schema markup to pages you expect search engines to read.
A quick check before you publish:
- Confirm the file sits at the root of the exact host you want to cover.
- Read each group and ask which crawlers will match it.
- Load the file in a browser and make sure the server answers with a normal success status.
Frequently asked questions
Does robots.txt keep a page out of Google?
Show answer
Not reliably. Google says it might still find and index a blocked URL that other pages link to, so a page you want hidden needs a different method, such as password protection.
Where should I put my robots.txt file?
Show answer
Put it at the root of each site address, next to the homepage. A copy inside a folder is ignored, and every subdomain needs its own file.
What happens if my robots.txt returns an error?
Show answer
A missing file is read as “no restrictions” for most 4xx responses. If your server is failing instead, Google pauses crawling at first and then leans on the last good copy it stored.
Will every bot follow my rules?
Show answer
No. The file only asks crawlers to behave, and nothing forces them to comply, so well-run search engines honor it while abusive bots may not.



