What is robots.txt?
A robots.txt file is a set of instructions for crawlers, placed at the top level of a site, for example at example.com/robots.txt. Before fetching pages, well-behaved bots read it to see which paths are off limits to them.
Google's documentation is explicit about its purpose: it is used mainly to avoid overloading a site with requests, and it is not a mechanism for keeping a web page out of Google.
How does robots.txt work?
The file is made of groups. Each group names a crawler and lists rules for it.
| Line | Meaning |
|---|---|
| User-agent: * | The rules below apply to every crawler |
| Disallow: /admin/ | Do not fetch any URL starting with /admin/ |
| Allow: /admin/help/ | An exception to the rule above |
| Sitemap: https://example.com/sitemap.xml | Where the sitemap is |
A group with an empty Disallow line allows everything. "Disallow: /" blocks the entire site for that crawler.
Robots.txt example
A typical small-site file has four lines: a User-agent line with an asterisk, a Disallow line for the admin or internal search path, an Allow line if an exception is needed, and a Sitemap line. Most sites need nothing more.
Does robots.txt disallow stop a page being indexed?
No. Disallow stops crawling. Google warns that a disallowed URL can still be indexed if other pages link to it, and may then appear in results as a bare address without a description. To keep a page out of search, Google says to use a noindex rule or password protection.
The two do not combine. If a page is blocked in robots.txt, the crawler never fetches it, so it never sees a noindex tag on that page.
| Goal | Use |
|---|---|
| Stop bots wasting requests on unimportant URLs | robots.txt Disallow |
| Keep a page out of search results | noindex, with crawling allowed |
| Keep content private | A login |
What are the limits of robots.txt?
- It is a request, not an enforcement. Google notes that reputable crawlers obey it and others may not.
- Crawlers can interpret syntax differently.
- The file is public, so it is no place to list secret paths.
- Blocking scripts or style files that a page needs can stop Google understanding the page.
Robots.txt and AI crawlers
AI companies publish the user-agent names of their crawlers, and the same file is where a site allows or disallows them. The decision is commercial: blocking a crawler used to fetch pages for AI answers also removes the chance of being cited in them.