Robots.txt Generator
Create a robots.txt file to control how search engines crawl your site — with the critical point that it is not a security or privacy mechanism.
Disallow does not keep a page out of search results
This is the misunderstanding that matters, because the fix people reach for makes it worse. Disallow controls crawling, not indexing. It tells a crawler not to fetch a URL. It says nothing about whether that URL may be listed, and search engines routinely list disallowed URLs they have learned about from links elsewhere — shown without a description, precisely because the crawler was never allowed to read the page.
Keeping something out of an index needs a noindex directive on the page itself. And
a noindex can only be obeyed if the crawler is allowed to fetch the page and see it. So this
combination, which looks like belt and braces, is self-defeating:
Disallow: /private/ ← in robots.txt <meta name="robots" content="noindex"> ← on the page
The Disallow prevents the crawler from ever reading the noindex. Pick one: allow crawling and use noindex, or accept that a disallowed URL may appear as a bare link.
For anything genuinely private, neither is the answer. robots.txt is a public file at a predictable address that lists exactly the paths you would rather people did not visit, and honouring it is entirely voluntary. If a URL must not be reached, it needs authentication, not a polite request.
And the longest matching rule wins, not the first
Rules are not applied in order. The most specific match — the longest pattern — decides, and where two patterns are the same length the less restrictive one wins, which means Allow. Reversing the order of the lines never changes the outcome.
That produces results which look wrong until you count characters. Given these rules:
Disallow: /admin/ Allow: /admin/public/ Disallow: /*.pdf$ Allow: /reports/
| Path | Result | Decided by | Length |
|---|---|---|---|
/admin/secret | Disallow | Disallow: /admin/ | 7 |
/admin/public/doc | Allow | Allow: /admin/public/ | 14 |
/reports/x.html | Allow | Allow: /reports/ | 9 |
/reports/x.pdf | Allow | Allow: /reports/ | 9 |
/a.pdf | Disallow | Disallow: /*.pdf$ | 7 |
/index.html | Allow | no rule — allowed by default | — |
The two bold rows are the surprise. /a.pdf is blocked, but
/reports/x.pdf is allowed — because /reports/ is nine
characters and /*.pdf$ is seven, so the Allow is the longer match and wins. A broad
Allow can override a narrow Disallow simply by being a longer string.
The practical consequence: writing rules in an order that reads correctly from top to bottom is no guarantee they behave that way, and the file gives no hint when they do not. Every result in that table is computed by a matcher checked against the documented precedence rules on each build, including the cases where length contradicts reading order.
The pattern that does work reliably is the nested one — block a directory, then permit one path inside it — and it works because the inner path is a longer string, not because it comes second. Google Search Console has a robots.txt tester that will tell you which line decided a given URL, which is faster than reasoning about it.
How to use
- Choose which crawlers the rules apply to.
- Add the paths you want to disallow.
- Add your sitemap location.
- Place the file at your site root and test it.
Frequently asked questions
Does robots.txt keep a page private?
No, and treating it as though it does is a genuine mistake. It is a publicly readable file of requests that well-behaved crawlers honour; anyone can fetch it, and listing a path there advertises exactly what you wanted hidden. Malicious crawlers ignore it entirely.
What is the difference between disallow and noindex?
Disallow asks a crawler not to fetch a page; noindex tells a search engine not to list it. They are different mechanisms and combining them wrongly backfires — a page blocked in robots.txt cannot be crawled, so the noindex tag on it is never seen, and it can still appear in results from external links.
How do I actually keep a page out of search results?
Use a noindex directive and allow the page to be crawled so the directive is read. For anything genuinely confidential, use authentication — search visibility and access control are separate problems, and only one of them is solved by a meta tag.
Where must the file live?
At the root of the domain, exactly at /robots.txt. It does not apply to subdomains, so each subdomain needs its own, and a file anywhere else is simply ignored. This catches people out on sites with several subdomains.
What is crawl-delay and does it work?
A request to slow a crawler's rate. Support varies — some crawlers honour it and Google does not, preferring its own rate controls. If crawl volume is a genuine problem, server-side rate limiting is the reliable answer.
Should I include my sitemap?
Yes — a sitemap directive in robots.txt is a standard way to point crawlers at it, and it works regardless of whether you have also submitted the sitemap directly. It costs one line and helps discovery on larger sites.
🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.