robots.txt guide: what it controls and what it does not, 2026
A robots.txt file manages which URLs crawlers request. It does not remove pages from search results or protect private content. Here is what it controls.

What robots.txt controls
A robots.txt file tells crawlers which URLs on your site they may request. It manages crawl traffic. It does not keep a page out of search results, and it does not protect anything private. Remember that and you'll avoid most of the mistakes people make with this file.

Google's documentation puts the purpose plainly: a robots.txt file is "used mainly to avoid overloading your site with requests", and it is "not a mechanism for keeping a web page out of Google." That wording was current as of November 2026.
This guide covers where the file lives, the four lines you will actually write, how rules are matched, what the file cannot do, and what to use instead.
Crawling is not indexing
Crawling means a bot requests a URL and reads it. Indexing means a search engine stores information about the page so it can appear in results. Robots.txt acts on the first step only. A page can be blocked from crawling and still be known to a search engine, because another site linked to it. The two are separate controls. Mixing them up causes most robots.txt trouble.
What you can sensibly block
Google lists three common uses by file type:
- Web pages: manage crawl load on a server that could be overwhelmed, or skip unimportant and duplicate URLs such as internal search results.
- Media files: manage crawl traffic for images, video and audio, and keep them out of Google Search results. Other pages can still link to them.
- Resource files: block scripts or styles only when the page does not depend on them. Do not block resources a crawler needs to understand how the page renders.
Where the file lives
The file must be named robots.txt, and a site can have only one. It belongs at the root of the host it governs. For www.example.com, that is https://www.example.com/robots.txt. Google's guide to writing the file says a copy in a subdirectory has no effect.
Scope is narrow: the rules apply only to the protocol, host and port where the file is posted. A file at https://example.com/robots.txt does not cover https://m.example.com/ or http://example.com/. Every subdomain that needs rules needs its own file.
The file must be UTF-8 encoded, written in a plain text editor. Word processors can save a proprietary format or insert curly quotes, and either one breaks parsing. The Robots Exclusion Protocol, standardized as RFC 9309, also specifies a text/plain media type.
To check that the file is public, open its URL in a private browsing window. If you can read it there, crawlers can too. Search Console has a robots.txt report for diagnosing problems on a file that is already live.
The four lines you will actually write
Most files use four directives:
- user-agent: names the crawler a group of rules applies to. It is required, and an asterisk matches all crawlers except Google's AdsBot crawlers, which must be named explicitly.
- disallow: a path the named crawler should not request. It starts with a slash.
- allow: a path that overrides a disallow, such as one page inside a blocked directory.
- sitemap: the full URL of a sitemap. It is optional, and you can list more than one. Use the exact URL, including
httpsand thewwwchoice you want.
A small example:
User-agent: *
Disallow: /search/
Disallow: /cart/
Allow: /search/help
Sitemap: https://www.example.com/sitemap.xml
This asks every crawler to skip /search/ and /cart/, except /search/help. Crawling is allowed by default, so you only list what you want to restrict. A # starts a comment, and every rule except sitemap supports the * wildcard.
Listing your sitemap here is a convenience, not a ranking lever. For the bigger picture on discovery, see our piece on sitemaps and indexation.
How rules are matched
A few matching details surprise people.
- Paths are case-sensitive.
/file.aspdoes not match/FILE.asp. - Rules match the start of the path.
Disallow: /privatealso covers/private-notesand/private/report. - The most specific rule wins. RFC 9309 defines this as the rule with the most matching characters. If an allow and a disallow are equally specific, the allow rule is used.
- No match means allowed. An empty group or a missing file imposes no restriction.
- Wildcards and end anchors.
*matches any sequence of characters, and RFC 9309 defines$as an end-of-URL marker. - Groups merge. If several groups match one crawler, their rules are combined. If none match, the
*group applies.
What happens when the file fails to load
The HTTP status of the robots.txt request matters. Under RFC 9309, a 2xx response means the crawler follows the rules. A 4xx response means the file is unavailable, and the crawler may access any resource on the server. A 5xx response or a network error means the file is undefined, and the crawler must assume a complete disallow. So a broken deploy that makes the file return a server error can pause crawling of your whole site.
What robots.txt does not do
It does not remove pages from search results
A blocked URL can still appear in results. Google says the result will show the address without a description when other sites link to it. The crawler never visited the page, so it knows nothing about its content, but it knows the URL exists.
Blocking can backfire. If a page is already indexed and you disallow it, the crawler can no longer fetch it to see updates or a removal signal.
It does not protect private content
The file is public, and anyone can read it. RFC 9309 notes that listing paths in it makes them visible, and that the protocol is not a form of access authorization. A Disallow: /admin-reports/ line tells a curious person exactly where to look.
Compliance is also voluntary. Google says robots.txt instructions cannot enforce crawler behavior: Googlebot and other reputable crawlers follow them, and others may not. For anything private, use authentication.
It does not guarantee uniform behavior
Crawlers can read the same syntax differently, and some do not understand every rule. Stick to the documented directives and test the crawlers you care about. The same caution applies to the newer bots from AI companies, which we cover in robots.txt choices for AI crawlers.
Use noindex when the goal is keeping a page out of results
If you want a page out of search results, use noindex. Google's noindex documentation describes two ways to set it:
- A meta tag in the page head:
<meta name="robots" content="noindex">. - An
X-Robots-Tag: noindexHTTP response header, which suits PDFs, images and video.
Google states the result directly: it "will drop that page entirely from Google Search results, regardless of whether other sites link to it."
There is one catch. Googlebot has to fetch the page to see the rule, so the page must not be blocked by robots.txt. If you disallow a URL and also add noindex, the crawler never reads the tag, and the URL can stay in results. Google also does not support a noindex rule written inside robots.txt itself.
To remove a page, work in this order: leave it crawlable, serve noindex, wait for a recrawl, and only then consider blocking it. Related controls such as canonical URLs solve a different problem, consolidating duplicates rather than hiding pages, and Google warns that combining crawling and indexing rules can make some rules cancel others.
Summary
Use robots.txt to steer crawl effort away from low-value URLs. Use noindex on a crawlable page to keep it out of results. Use authentication for anything private. If your site needs a technical SEO review, our SEO and AEO service covers crawl and indexing setup.
Frequently asked questions
Does robots.txt remove a page from Google?
No. Robots.txt controls crawling, not indexing, and a blocked URL can still appear in results without a description if other sites link to it. To remove a page, serve noindex on a crawlable page or put it behind a password.
Where does the robots.txt file go?
At the root of each host, for example https://www.example.com/robots.txt. It applies only to that protocol, host and port, so a subdomain needs its own file.
Can I put noindex in robots.txt?
Not for Google. Google does not support a noindex rule inside robots.txt. Use a meta robots tag or an X-Robots-Tag header on the page itself.
Is robots.txt a way to hide private pages?
No. The file is public, so listing a path advertises it, and compliance is voluntary. Use authentication for anything private.
What happens if my robots.txt returns an error?
Under RFC 9309, a 4xx response means crawlers may access everything, while a 5xx response or network error is treated as a full disallow. Keep the file returning 200 after every deploy.