Your robots.txt file is one of the smallest files on your website and one of the easiest to get badly wrong. A single stray line can wall off your best pages from Google, or quietly let low-value URLs eat the crawl attention you wanted on money pages. In this 2026 guide I'll explain exactly what robots.txt does, what it can't do, and how to use it to steer crawlers without shooting yourself in the foot.
I've audited hundreds of sites over the last six years, and robots.txt problems show up far more often than they should. Usually it's not a dramatic outage. It's a subtle line copied from a staging server, a wildcard that matched more than intended, or a well-meaning "block everything we don't need" rule that also blocked the CSS Google needs to render the page.
The good news: once you understand the model behind robots.txt, it becomes a precise, reliable tool. Let's start with the single most misunderstood thing about it.
What Robots.txt Actually Does (and Doesn't)
Robots.txt is a crawl-control file, not an index-control file. It tells cooperating crawlers which paths they may request. It does not, by itself, keep a page out of Google's index. That distinction is the root cause of most robots.txt mistakes I see.
Here's the trap: if you Disallow a URL, Google won't crawl it, but it can still index the URL (often as a bare link with no description) if other pages link to it. So blocking a page you actually want removed from search can backfire, because Google can't see the noindex tag on a page it's not allowed to crawl.
What robots.txt controls vs. what it doesn't
- Controls crawling: which URLs well-behaved bots are allowed to fetch.
- Helps crawl efficiency: keeps bots away from infinite or low-value URL spaces.
- Points to sitemaps: a
Sitemap:line helps discovery. - Does NOT guarantee removal from Google: blocked URLs can still be indexed as links.
- Does NOT enforce security: it's a public file; never use it to "hide" sensitive paths.
- Does NOT bind bad bots: only cooperative crawlers obey it; scrapers ignore it.
When you truly want a page out of search, the right tool is a noindex meta tag or header on a page that stays crawlable — a point I cover in more depth in my guide to pages that won't index. Robots.txt is for managing crawl access, and that's how we'll treat it throughout this article.
How Robots.txt Works: Syntax and Directives
The file lives at one fixed location: the root of your domain, at https://yourdomain.com/robots.txt. Crawlers check it before requesting other URLs on that host. Each subdomain and protocol needs its own file — blog.yourdomain.com and the www version are separate hosts as far as robots.txt is concerned.
The syntax is plain text, grouped into records. Each record starts with one or more User-agent lines naming the bot, followed by rules that apply to it. According to Google Search Central's robots.txt documentation, Google reads the most specific matching group for its crawler.
The core directives you'll actually use
- User-agent: names the crawler the rules apply to (
*means all bots). - Disallow: a path prefix bots should not crawl (an empty value means "allow all").
- Allow: carves an exception inside a disallowed path; more specific rules win.
- Sitemap: an absolute URL to your XML sitemap; you can list several.
- Wildcards:
*matches any characters and$anchors the end of a URL. - Comments: anything after
#on a line is ignored by crawlers.
One nuance that trips people up: Crawl-delay is not supported by Google, so don't rely on it to slow Googlebot — you manage Google's crawl rate through crawl demand and server health instead, which ties directly into how you manage crawl budget on larger sites.
Robots.txt vs. Meta Robots vs. Canonical
These three tools get confused constantly because they all touch how search engines treat a page. But they solve different problems, and using the wrong one is exactly how good pages disappear or duplicates linger. Here's how I keep them straight for clients.
| Tool | What it controls | Use it when | Key limitation |
|---|---|---|---|
| Robots.txt Disallow | Whether a URL is crawled | You want bots to skip a URL space entirely (e.g. faceted params) | Blocked URLs can still be indexed as links; noindex won't be seen |
| Meta robots / X-Robots-Tag | Whether a crawled page is indexed | You want a page removed from or kept out of search results | The page must stay crawlable for the tag to be read |
| Rel=canonical | Which duplicate is the preferred URL | You have near-duplicate pages and want to consolidate signals | It's a hint, not a directive; Google can ignore it |
The rule of thumb: use robots.txt to save crawling on stuff that has no business being fetched, use meta robots to control what appears in results, and use canonical tags to consolidate duplicates. Never combine a Disallow with a noindex on the same URL — Google can't read the noindex if it's not allowed to crawl the page.
The Highest-Value Uses of Robots.txt
For a small, clean site you may not need much in robots.txt at all beyond a sitemap line. The file earns its keep on larger, more complex sites where crawlers can waste time on URLs that will never rank. Here's where I get the most mileage.
Where robots.txt pays off
- Faceted and filter URLs: block parameter combinations that generate near-infinite variations.
- Internal search results: stop bots crawling your on-site search pages.
- Cart, checkout, and account paths: functional URLs with no search value.
- Staging or duplicate directories: keep bots out of non-canonical copies (better still, password-protect them).
- Heavy dynamic endpoints: APIs or export URLs that strain the server for no ranking benefit.
- Sitemap discovery: always include at least one
Sitemap:line pointing at your live XML sitemap.
Notice a theme: you block things that either don't belong in search or would waste crawl attention. You do not block things you want to rank. This is core technical SEO hygiene, and it's one of the first things I check in any audit alongside the broader technical SEO audit checklist.
How To Set Up a Robots.txt File Step by Step
You don't need a plugin or a developer to get this right. A plain text file and a little care will do. Here's the sequence I follow when creating or cleaning up a robots.txt.
Map what should stay crawlable
List your important sections first — anything you want ranked must remain fully accessible, including the CSS and JavaScript Google needs to render pages. Start from "allow everything" and only subtract.
Write targeted disallow rules
Add Disallow lines only for the low-value URL patterns you identified. Use wildcards deliberately, and test each pattern against real URLs so you don't over-match.
Add your sitemap line
Include an absolute Sitemap: URL for each sitemap or sitemap index. This helps crawlers discover new and updated pages faster.
Upload to the root and verify
Place the file at your domain root and load /robots.txt in a browser to confirm it returns a 200 status and the exact content you expect. Each host needs its own file.
Test before you trust it
Run your key URLs through a tester to confirm allowed pages are allowed and blocked pages are blocked. Only then do you walk away.
Costly Robots.txt Mistakes That Hurt SEO
Because the file is so short, people assume it's low-risk. It's the opposite: a two-character change can affect your entire site. These are the errors I see cause real ranking damage.
Mistakes to avoid
- Blocking the whole site: a leftover
Disallow: /from staging is the classic launch-day disaster. - Blocking CSS/JS: if Google can't fetch render resources, it may misjudge your mobile usability and layout.
- Using it to hide pages from search: disallowed URLs can still appear as indexed links; use noindex instead.
- Over-broad wildcards: a pattern like
*?can catch far more than the parameters you meant. - Blocking a URL that also has noindex: Google never sees the noindex, so the page can linger in the index.
- Forgetting subdomains: your main file doesn't cover
shop.orblog.subdomains.
If your traffic dropped and you can't explain it, robots.txt is one of the first files I'd check — right alongside indexing status. I walk through that diagnostic path in detail when clients ask why pages aren't getting indexed, and a bad disallow rule is a surprisingly common culprit.
How To Test and Monitor Your Robots.txt
Setting the file is not the end — you monitor it, because CMS updates, plugins, and developers can rewrite it without warning. I've seen a plugin update silently replace a carefully tuned file with a default that blocked half a store.
Google Search Console is your main safety net here. The robots.txt report shows the fetched version and flags parsing issues, and URL Inspection tells you whether a specific URL is blocked. If you haven't connected it yet, my Analytics and Search Console setup service covers exactly this, and you can dig deeper in the full Search Console guide.
Your monitoring routine
- Check the GSC robots.txt report: confirm Google fetched the version you intended.
- Spot-check key URLs: use URL Inspection to verify important pages aren't blocked.
- Watch crawl stats: a sudden crawl drop can signal an accidental block.
- Re-test after any deploy: treat robots.txt as code that can regress.
- Keep a known-good copy: so you can restore instantly if something overwrites it.
Controlling AI Crawlers With Robots.txt
This is the part that's genuinely new in 2026. Beyond Googlebot and Bingbot, a wave of AI crawlers now request your content to train models or answer questions in tools like ChatGPT and Perplexity. Robots.txt is the main lever you have to allow or deny them, since most of the reputable ones honor it.
Whether you should block them is a strategy call, not a technical one. Blocking training crawlers protects your content but can also reduce your visibility in AI answers — a real trade-off I talk through with clients rather than applying a blanket rule. If AI-search visibility matters to you, working with the best SEO expert you can find pays off, because the right choice depends on your business model, not a default.
Common AI crawler user-agents
- GPTBot: OpenAI's crawler used for training data collection.
- Google-Extended: a token that controls use of your content for Google's generative AI, separate from Googlebot.
- CCBot: Common Crawl's bot, whose dataset feeds many AI models.
- PerplexityBot: used by Perplexity's answer engine.
- ClaudeBot: Anthropic's crawler for its AI assistant.
Importantly, blocking Google-Extended does not affect your normal Google Search rankings — it only governs generative-AI use. Keep those decisions separate so you don't accidentally harm classic SEO while managing AI access.
Frequently Asked Questions
Does robots.txt remove a page from Google?
No. Disallowing a URL stops Google from crawling it, but the URL can still be indexed if other pages link to it. To remove a page from search, keep it crawlable and add a noindex tag, or use the removals tool for urgent cases.
Where should the robots.txt file be located?
At the root of each host, for example https://yourdomain.com/robots.txt. It only applies to that exact protocol and subdomain, so www and non-www, HTTP and HTTPS, and each subdomain need their own file.
Do I even need a robots.txt file?
Small, clean sites can run fine without special rules, but I still recommend having one that at least points to your sitemap. On larger sites it becomes essential for steering crawl attention away from low-value URLs.
Will blocking AI crawlers hurt my SEO?
Blocking dedicated AI crawlers like GPTBot or Google-Extended does not affect your Google Search rankings, which depend on Googlebot. It only limits whether your content is used in AI training or generative answers, so weigh visibility against control.
Conclusion: A Small File That Deserves Real Attention
Robots.txt rewards precision. Get the mental model right — crawl control, not index control — and the rest falls into place: block the URL spaces that waste crawler time, keep everything you want to rank fully accessible, and never lean on it to hide pages that need a proper noindex. The biggest wins usually come from removing bad rules, not adding clever ones.
Review your file today, test your most important URLs, and set a reminder to re-check after every major site change. If you'd rather have an expert audit it as part of a broader complete SEO review, that's exactly the kind of quiet, high-leverage fix I love finding — the sort that quietly recovers rankings a site didn't know it was losing.
Worried Your Robots.txt Is Costing You Rankings?
Let me audit your crawl setup, fix risky rules, and make sure Google and AI crawlers see exactly what you want them to. A quick review can prevent months of lost traffic.
Book a Free Consultation