Every website gets visited by crawlers: search engine bots fetching pages to index, and plenty of others besides. Most of the time you want them to crawl freely. But almost every site has areas that are useless or wasteful for a crawler to fetch, such as an admin section, temporary folders or internal search results. The robots.txt file is how you tell crawlers which paths to leave alone.
This guide explains how a robots.txt file is put together and how to build one with the free Robots.txt Generator on Ovatly, which turns visual rule groups into the plain text file you place at the root of your domain. It also covers the limit people most often get wrong: robots.txt controls crawling, not indexing and not security.
Contents
- Quick answer
- What a robots.txt file actually is
- Rule groups: user agents, Disallow and Allow
- Crawl-delay and the Sitemap line
- How to create a robots.txt file, step by step
- Worked example: blocking an admin area for every crawler
- Limitations: what robots.txt cannot do
- Common mistakes
- FAQs
- Conclusion
Quick answer
A robots.txt file is plain text that lives at the root of your domain, for example https://example.com/robots.txt. It is organised into rule groups. Each group names one or more user agents (the crawlers the rules apply to, with * meaning all crawlers), then lists Disallow paths those crawlers should not fetch and Allow paths that reopen parts of a blocked section. You can add an optional crawl-delay and one or more Sitemap lines pointing to your sitemap addresses. Open the Robots.txt Generator, fill in one group per set of rules, add your sitemap URL, then copy or download the file and place it at your domain root. Test it before you upload, and remember that the file controls crawling only: it cannot hide a page, protect it or remove it from search results.
What a robots.txt file actually is
robots.txt is a small text file that crawlers look for before they start fetching pages on a host. It is a set of instructions about which paths a crawler may and may not fetch. Well-behaved crawlers read it and follow it. That is the whole mechanism: there is no password, no enforcement and no effect on human visitors, who never see the file unless they type its address themselves.
Two consequences follow from that design, and both matter. First, the file is public. Anyone can read your robots.txt, which is why you should never list secret paths in it: a Disallow line is effectively a signpost saying "something is here". Second, blocking a path stops a crawler from fetching it, but it does not stop the URL from existing or from being known about. If other sites link to a blocked page, that page can still appear in search results, shown as a bare URL without a snippet, because the search engine knows the address but is not allowed to fetch the content.
Rule groups: user agents, Disallow and Allow
The file is built from rule groups. A group starts with one or more User-agent lines naming the crawlers the group applies to. The value * means all crawlers. A group that names a specific crawler applies to that crawler instead of the general group.
Under the user agents come the path rules:
- Disallow names a path prefix the group's crawlers should not fetch. Disallow: /admin/ blocks everything under the admin folder.
- Allow reopens a more specific path inside a disallowed area. If a whole section is blocked but one public page sits inside it, an Allow line for that page lets crawlers fetch it. When both an Allow and a Disallow pattern match a path, the longest pattern wins.
- An empty Disallow: line, with nothing after it, means nothing is blocked for that group. It is the standard way to say "this group may crawl everything".
Most sites need only one group, the * group covering every crawler. Add a second group only when one crawler genuinely needs different rules from the rest, because each extra group is another place for a contradiction to hide.
Crawl-delay and the Sitemap line
Two optional lines round out the file. Crawl-delay asks crawlers to wait a number of seconds between requests. Support is uneven: it is honoured by some crawlers, for example Bing, but ignored by Googlebot. Treat it as a polite request that some visitors will follow, not as a throttle you control.
The Sitemap line gives the full address of your sitemap file, for example https://example.com/sitemap.xml. It is how you point crawlers at the list of pages you most want discovered. If you have not built a sitemap yet, the companion guide on creating an XML sitemap walks through it, and the generator can include the address in your robots.txt as soon as you have one.
How to create a robots.txt file, step by step
- Open the Robots.txt Generator. In the first group, list the user agents the rules apply to. Use * for all crawlers unless one crawler needs its own group.
- Add the Disallow paths you want to block and any Allow paths that reopen part of a blocked section, one per line.
- Add another group only if one crawler needs different rules. Set a crawl-delay if you want one.
- Add your sitemap URL, then copy or download the generated robots.txt.
- Before uploading, run the content through the Robots.txt Tester with a few real paths from your site, especially anything you meant to keep crawlable. Then place the file at the root of your domain so it answers at https://yourdomain/robots.txt.
Worked example: blocking an admin area for every crawler
Say your site keeps its admin screens under /admin/ and uses a /tmp/ folder for temporary files, and your sitemap lives at https://example.com/sitemap.xml. One group is enough: user agent *, Disallow paths /admin/ and /tmp/, and the sitemap address. The generator produces exactly this file:
User-agent: *
Disallow: /admin/
Disallow: /tmp/
Sitemap: https://example.com/sitemap.xml
Read it top to bottom: every crawler is told not to fetch anything under /admin/ or /tmp/, everything else on the site is fair game, and crawlers are pointed at the sitemap for the pages you do want found. Note what the file does not do: it does not password-protect the admin area, and the admin address is now written down in a public file. Real access control still has to happen on the server.
Limitations: what robots.txt cannot do
- It does not control indexing. A disallowed page can still appear in search results if other sites link to it. To remove a page from results, use a noindex tag or remove the page.
- It is not security. The file is public and crawlers can ignore it. Never list secret paths in it, and never rely on it to protect anything.
- Crawl-delay is partial. Some crawlers honour it, Googlebot ignores it.
- It works per host. The file must live at the root of the host, and each subdomain needs its own file with its own rules.
Common mistakes
- Trying to hide pages with robots.txt. Blocking an indexed page usually keeps the URL in results without a snippet. Use noindex or remove the page instead.
- Listing sensitive paths. Every Disallow line advertises that the path exists. Keep private areas out of the file and protect them properly.
- Blocking the whole site by accident. A Disallow: / line in the * group tells every crawler to fetch nothing. Check the file with the tester before it goes live.
- Putting the file in a subfolder. Crawlers only look at the root of the host. A robots.txt anywhere else is ignored.
- Assuming one file covers subdomains. It does not. Each subdomain needs its own file at its own root.
- Skipping the test. A single wrong path can block your most important pages. A two-minute check with real paths catches it.
FAQs
What is the difference between Allow and Disallow? Disallow tells crawlers not to fetch paths under a prefix; Allow reopens a more specific path inside a disallowed area. When both match, the longest pattern wins.
Does an empty Disallow line matter? "Disallow:" with nothing after it means nothing is blocked for that group. The generator only writes Disallow lines for paths you actually enter.
How do I test the file before uploading it? Use the Robots.txt Tester on this site with the generated content and a few real paths from your site, especially anything you meant to keep crawlable.
Can robots.txt remove a page from Google? No. Blocking a page that is already indexed usually keeps the URL in results without a snippet. Use a noindex tag or remove the page for deindexing.
Does every subdomain need its own robots.txt file? Yes. The file must live at the root of the host, for example https://example.com/robots.txt, and each subdomain needs its own file.
Conclusion
A good robots.txt file is short, deliberate and tested: one group for all crawlers in most cases, Disallow lines only for paths that genuinely waste crawl effort, Allow lines where a blocked section holds a public page, and a Sitemap line pointing at the pages you want found. Build it with the Robots.txt Generator, check it with the tester, and keep its limits in mind: it steers crawlers, it does not guard or hide anything. For more tools like this, browse the SEO Tools guides collection.