Robots.txt Guide: What It Does, What It Does Not Do and the Mistakes That Block Pages
Robots.txt is a plain text file at the root of a site that tells crawlers which URLs they may fetch. It manages crawling, mainly to protect the server. It is not a way to keep a page out of Google: a blocked address can still be indexed, and removing a page from results needs noindex or a password.
Prabhu SolutionsPublished 24 October 2026Last reviewed 24 October 202614 min read
On this page
- What is robots.txt?
- Does robots.txt remove a page from Google?
- Where does robots.txt go, and what are its basic rules?
- What is the syntax of a robots.txt file?
- How does Google decide which robots.txt rule applies?
- Should you use noindex or disallow?
- Never block a page you have marked noindex
- Which robots.txt mistakes block pages from Google?
- How do you test a robots.txt file?
- When is robots.txt worth using, and when can you leave it alone?
- How does Prabhu Solutions handle robots.txt in technical SEO work?
- Sources
What is robots.txt?
Robots.txt is a small text file, kept at the top level of a website, that lists which parts of the site crawlers may and may not request. Google describes its main job as managing crawler traffic so a server is not overloaded. It is a request that well-behaved crawlers honour, not a lock, and it says nothing about what should appear in search results.
Crawlers that follow the standard check the file before they request other pages on a host. If the file allows a path, the crawler may request it; if the file disallows it, the crawler skips it. If there is no file, or the crawler cannot read it in a way that applies, the default is that everything may be crawled.
The file is easy to write and easy to get dangerously wrong, because one line can shut out an entire site and nothing in the browser warns you. This guide covers what robots.txt does, the single thing people most often assume it does and does not, the syntax, the choice between disallow and noindex, the mistakes that block pages, and how to test the file. For the wider context of crawling and indexing, what technical SEO covers is the better starting point.
The point
The file is easy to write and easy to get dangerously wrong, because one line can shut out an entire site and nothing in the browser warns you.
Does robots.txt remove a page from Google?
No. Google's documentation says robots.txt is not a mechanism for keeping a web page out of Google. If other pages link to a blocked address, Google may still index the address, and the listing can appear with no description. To keep a page out of results, use a noindex directive or password protection.
The confusion is understandable. Blocking a page does stop Google fetching its content, so it feels as if the page has been hidden. But Google decides what to list from what it knows about the address, including the links pointing at it and their anchor text. It can know the address exists without ever reading the page. In Search Console, this appears as a warning: indexed, though blocked by robots.txt.
The same logic makes the commonest well-intentioned mistake worse. If you disallow a page that carries a noindex tag, Google cannot fetch the page, never sees the tag, and the noindex does nothing. Google states that the page must not be blocked by robots.txt for noindex to be seen. The sections below on noindex and disallow settle which to choose. For the case where a page is missing from Google and you do not know why, why a site is not indexed works through the reasons.
The point
If you disallow a page that carries a noindex tag, Google cannot fetch the page, never sees the tag, and the noindex does nothing.
Where does robots.txt go, and what are its basic rules?
A robots.txt file must be called exactly robots.txt, saved as plain UTF-8 text, and placed at the root of the host it governs. It applies only to the protocol, host and port where it sits, so a subdomain needs its own file. Crawlers cache it, so changes are not instant.
| Topic | What applies | Why it matters |
|---|---|---|
| Location | At the root of the host, for example the address of your site followed by /robots.txt. It cannot live in a subdirectory. | A file in a folder is simply ignored. |
| Name and format | Exactly robots.txt, plain text, UTF-8. Use a text editor, not a word processor, which can insert curly quotes. | Stray characters can stop a rule being read. |
| Scope | One file per protocol, host and port. The file on one subdomain does not cover another. | A shop on its own subdomain needs its own rules. |
| Size | Google enforces a limit of 500 KiB. Anything beyond it is ignored. | Very long rule lists can silently lose their ending. |
| Caching | Google generally caches the file for up to 24 hours, and may keep an older copy longer if it cannot refresh it. | A fix may take a day to take effect. The robots.txt report in Search Console can request a faster refresh. |
| If the file is missing | Google treats a 4xx response, other than 429, as if no valid file existed, so nothing is restricted. | A deleted file means everything may be crawled. |
| If the server fails | On a 5xx response Google stops crawling the site for the first 12 hours, then uses the last good copy for up to 30 days. | A broken server can briefly pause crawling of the whole site. |
| Redirects | Google follows at least five redirect hops for the file, then treats the result as not found. | Avoid redirecting the file at all where you can. |
What is the syntax of a robots.txt file?
A robots.txt file is a list of groups. Each group begins with a User-agent line naming a crawler, followed by Disallow and Allow lines that give paths. A Sitemap line can sit anywhere. The table reads an example file line by line, with the effect of each.
| Line | What it does |
|---|---|
| User-agent: * | Starts a group that applies to all crawlers, except Google's AdsBot crawlers, which must be named explicitly. |
| Disallow: /basket/ | Asks the crawler not to fetch any address whose path begins with /basket/. Paths start with a slash. |
| Disallow: /search | Blocks any path starting with /search, including /search?q=boots and also /searchlight, because matching is by prefix. |
| Allow: /search/help/ | Makes an exception inside a blocked area. The more specific rule wins. |
| Disallow: /*?sort= | Uses an asterisk as a wildcard for any run of characters, blocking sorted copies of a listing page. |
| # internal pages | A comment. Everything after a hash on a line is ignored. |
| Sitemap: https://www.example.co.uk/sitemap.xml | Gives the full address of an XML sitemap (see what a sitemap is). It must be a fully qualified address. |
How does Google decide which robots.txt rule applies?
Google applies the most specific matching rule, meaning the one with the longest path, and where two rules conflict it uses the least restrictive. Each crawler follows only the single group that best matches its own name, so a named group is never combined with the star group.
- Only four fields are supported: user-agent, allow, disallow and sitemap. Others, such as crawl-delay, are not supported by Google.
- Path values are case-sensitive. A rule for /Shop does not cover /shop, so check the exact case your site uses.
- A rule path matches by prefix. Disallow: /fish covers /fish.html and /fishheads, but not /catfish.
- An asterisk stands for any sequence of characters. A dollar sign at the end of a path marks the end of the address, so a rule ending that way matches addresses that end there and not ones with a query string added.
- The user-agent name and the field names are not case-sensitive, but the paths in rules are.
- If an Allow and a Disallow rule are equally specific, the Allow wins. If a longer Disallow rule meets a shorter Allow rule, the longer rule wins.
- Groups can appear in any order. Several groups naming the same crawler are merged, but a group for a specific crawler is not merged with the group for all crawlers.
Should you use noindex or disallow?
Use disallow to stop crawlers wasting effort on addresses nobody needs found, and noindex to keep a page out of search results. They solve different problems and cannot be combined on one page, because a page blocked by robots.txt never has its noindex tag read.
| What you want | Use | Why |
|---|---|---|
| Keep a page out of Google results | A noindex meta tag or X-Robots-Tag header, with the page left crawlable. | Google must be able to fetch the page to read the directive. Robots.txt does not support noindex. |
| Keep a page private from everyone | Password protection or other access control. | Robots.txt is voluntary and public. Anyone can read the file and see the paths it names. |
| Stop crawlers fetching low-value URLs, such as basket and internal search pages | Disallow in robots.txt. | It saves crawl effort on pages with no search value. |
| Remove a page that is already in Google results | Noindex or deletion, kept crawlable until it drops out, then your choice of blocking. | A page you block immediately can stay listed because Google cannot see the change. |
| Consolidate duplicate pages | Redirects or rel=canonical, not robots.txt. | Google advises against robots.txt for canonicalisation. See the SEO migration checklist for handling moves. |
| Keep images or videos out of Google Search | Robots.txt rules for those files can help. | Google notes this applies to media files, though other pages can still link to them. |
Never block a page you have marked noindex
If a page carries a noindex tag and is also disallowed in robots.txt, Google cannot fetch it, never reads the tag, and may still list the address if other sites link to it. To remove a page from results, leave it crawlable, keep the noindex in place until it has dropped out, and only then consider blocking it.
Which robots.txt mistakes block pages from Google?
The mistakes that cost most are a Disallow of the whole site copied over from staging, rules that block the scripts and styles a page needs to render, and rules too broad for their purpose. Each can hide valuable pages without any visible error on the site.
| Mistake | What happens | How to avoid it |
|---|---|---|
| A leftover Disallow: / from the staging site | The whole site is closed to crawlers after launch. Pages work for visitors and slowly vanish from search. | Read the live robots.txt on launch day, before anything else. See what a controlled site move involves for how that check fits into a migration. |
| Blocking script and style folders | Google cannot render the page as a visitor sees it. Google advises against blocking resources that help it understand a page. | Block only resources that are truly unimportant and whose loss does not change the page. |
| A rule path that is too short | Because matching is by prefix, Disallow: /pro also blocks /products and /promotions. | Write the path as completely as you can, ending a folder with a slash. |
| Wrong case in a path | Rules are case-sensitive, so a block meant for /Admin may not cover /admin, or the reverse. | Copy the exact path from live addresses. |
| Blocking pages that have a noindex tag | The tag is never read, so the address can stay listed. | Keep noindex pages crawlable. |
| Using it to hide sensitive pages | The file is public, so it advertises the paths it names, and not every crawler obeys it. | Use authentication for anything that must stay private. |
| Putting the file in the wrong place | A file on the wrong host, in a folder, or on a different subdomain is not read for the site you meant. | Check the file at the root of each host. |
| Relying on an unsupported field | Crawl-delay and noindex lines inside robots.txt have no effect on Google. | Use Search Console and server settings instead. |
How do you test a robots.txt file?
Test in three steps: confirm the file is publicly reachable, check the rules are read as you intended, then check that your important pages are not blocked. Google provides a robots.txt report in Search Console and an open source library for local testing, and the inspection tool will name a block on any single address.
- Open the file in a private browsing window at the root of the host, so you see what a crawler sees and not a cached or logged-in version.
- Open the robots.txt report in Search Console to check how Google reads the file and whether it finds any problems with its markup.
- Inspect important addresses with the URL Inspection tool, and look in the Page indexing report, which lists pages the file blocks as blocked by robots.txt.
- Compare the rules with your live address list. Look especially at folders that hold scripts, styles, images and anything that earns enquiries.
- After editing, upload the new file and request a recrawl of the file from the robots.txt report if you cannot wait for the cache to refresh.
- Test again after any release, platform update or plugin change, because many content management systems write to the file for you, and a custom build from a website development team should have the file in its launch checklist. Ongoing website maintenance is where that habit usually lives.
- For a more technical check, Google's open source robots.txt parser can be run locally against your file and a list of addresses before the file goes live.
When is robots.txt worth using, and when can you leave it alone?
Use it to keep crawlers away from addresses with no search value: baskets, account areas, internal search results and endlessly sortable listings, the last of which is a familiar problem on ecommerce SEO projects. A small site with no such areas can have a very short file or almost none. The file is a tool for a specific job, and an empty, valid file is a perfectly acceptable answer.
It is not a crawl budget lever for small sites. Google's guidance on crawl budget is aimed at sites with roughly a million or more pages, or ten thousand or more that change daily, and it says not to use robots.txt to temporarily reallocate crawl budget to other pages. Blocked addresses also stay in the crawl queue for a long time and are recrawled once the block lifts.
Whether to admit or refuse crawlers other than Google's is a separate business decision, since each crawler follows the group naming itself and compliance is voluntary. The trade-offs are discussed in our note on letting AI crawlers read your site. Whatever you decide, do it deliberately in the file rather than by accident through a broad rule.
The point
Whether to admit or refuse crawlers other than Google's is a separate business decision, since each crawler follows the group naming itself and compliance is voluntary.
How does Prabhu Solutions handle robots.txt in technical SEO work?
As part of a crawl and indexation review: we read the live file, compare it with the pages that should be found, and flag blocks, leftover staging rules and missing sitemap references. Prabhu Solutions is registered in Oldbury, West Midlands, works with businesses across the UK and delivers remotely. How we approach technical SEO explains where this check sits among the others.
We do not treat robots.txt as a ranking lever, and we do not promise that editing it will change your position. The file affects whether pages can be reached, which is a precondition for ranking, not a cause of it. What an SEO audit includes shows how the check is reported, and what is SEO and how does it work gives the wider picture for anyone new to the subject, and our SEO service page sets out the wider programme this check belongs to.
If you suspect your file is blocking the wrong things, send us the address and we will read it. Searching for help by city is common; if you are looking for local SEO in Birmingham, our page on the area explains what working from a registered address in Oldbury, remotely, means in practice. Page speed is a separate subject, covered in the Core Web Vitals guide.
The point
If you suspect your file is blocking the wrong things, send us the address and we will read it.
Sources
Every statement about Google's behaviour on this page comes from Google Search Central documentation, read and checked on the date shown.
- Google Search Central, Introduction to robots.txt (developers.google.com/search/docs/crawling-indexing/robots/intro): purpose, not a way to keep a page out of Google, disallowed URLs can still be indexed, media and resource files, voluntary compliance. Checked 24 October 2026.
- Google Search Central, Create and submit a robots.txt file (developers.google.com/search/docs/crawling-indexing/robots/create-robots-txt): location, name, UTF-8, rules, testing. Checked 24 October 2026.
- Google Search Central, How Google interprets the robots.txt specification (developers.google.com/search/docs/crawling-indexing/robots/robots_txt): supported fields, wildcards, prefix and case matching, precedence, scope, 500 KiB limit, HTTP status handling, caching. Checked 24 October 2026.
- Google Search Central, Update your robots.txt file (developers.google.com/search/docs/crawling-indexing/robots/submit-updated-robots-txt): 24-hour cache and requesting a recrawl in the robots.txt report. Checked 24 October 2026.
- Google Search Central, Block search indexing with noindex (developers.google.com/search/docs/crawling-indexing/block-indexing): noindex by meta tag or header, not supported in robots.txt, page must not be blocked. Checked 24 October 2026.
- Google Search Central, Robots meta tag, data-nosnippet and X-Robots-Tag specifications (developers.google.com/search/docs/crawling-indexing/robots-meta-tag): rules are read only when crawlers can access the page. Checked 24 October 2026.
- Google Search Central, How to specify a canonical URL (developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls): do not use robots.txt for canonicalisation. Checked 24 October 2026.
- Google Search Central, Managing crawl budget for large sites (developers.google.com/search/docs/crawling-indexing/large-site-managing-crawl-budget): size thresholds, not for reallocating crawl budget, blocked URLs stay in the queue. Checked 24 October 2026.
- Google Search Console Help, Page indexing report (support.google.com/webmasters/answer/7440203): blocked by robots.txt and indexed though blocked. Checked 24 October 2026.
Questions people ask about this
What is robots.txt used for?
It tells crawlers which parts of your site they may request, mainly so that a server is not overloaded by pointless crawling. It suits baskets, internal search results and endless filtered listings. It is not a privacy tool and it is not a reliable way to keep a page out of Google.
Does a robots.txt disallow stop my page appearing in Google?
Not reliably. Google says it may still index a disallowed address if other pages link to it, though the listing usually has no description. To keep a page out of results, leave it crawlable and add a noindex tag or header, or put the page behind a password.
Where should my robots.txt file be placed?
At the root of each host, for example your site's address followed by /robots.txt. It cannot sit in a subfolder, and it applies only to the protocol, host and port where it is placed. A subdomain needs its own file. Name it exactly robots.txt and save it as plain UTF-8 text.
Can I put noindex in robots.txt?
No. Google does not support a noindex rule inside robots.txt. Use a robots meta tag in the page head, or an X-Robots-Tag HTTP header for files such as PDFs, and make sure the page is not blocked, because Google has to fetch the page to read either one.
How long does a robots.txt change take to work?
Google generally caches the file for up to 24 hours, so a change may take about a day to be picked up. If you cannot wait, you can request a recrawl of the file from the robots.txt report in Search Console. Pages blocked earlier are recrawled once the block lifts.
Does a missing robots.txt file hurt SEO?
No. If Google receives a not-found response for the file, it treats it as if there were no restrictions and crawls everything it can. A site with nothing to block does not need rules, and a short valid file is just as acceptable. Add one only when there are addresses you want crawlers to skip.
Should I block CSS and JavaScript files in robots.txt?
Generally not. Google advises against blocking resources that help it understand a page, because it needs them to render the page as a visitor sees it. Block a script or style file only when it is unimportant and the page does not change significantly without it.
How do I check whether robots.txt is blocking a page?
Paste the address into the URL Inspection tool in Search Console and read its status, and open the robots.txt report to check how Google reads the file. The Page indexing report also lists pages as blocked by robots.txt. Fix the rule, upload the file and inspect the page again.
Is robots.txt public?
Yes. Anyone can open the file and read it, so it advertises the paths it names. Never use it to conceal sensitive areas, and remember that compliance is voluntary: reputable crawlers follow it, others may not. Use authentication for anything that must stay private.
Read next
What Is Technical SEO? How Search Engines Reach Your Pages and What to Fix First
Technical SEO is the work that lets a search engine reach, read and index your pages. Here is how that pipeline works, what the work covers, what canonical tags do and what to fix first.
Why Isn't My Site Indexed by Google? How to Read the Page Indexing Report
Pages go unindexed for a handful of reasons: blocking, noindex, conflicting canonicals, redirects, errors, weak content, or Google not having reached them yet. Here is how to tell which, and what to do.
What Does an SEO Audit Include? A Plain Guide to the Checklist and the Report
An SEO audit should examine nine things and rank what it finds. Here is each check, what a real report looks like next to a tool printout, and when an audit is the wrong first step.
