Here’s how to get robots.txt seo right. A single misplaced character in robots.txt can deindex an entire site overnight, and most teams only notice when traffic falls off a cliff. Setting up robots.txt for SEO correctly is a 20-minute job that prevents some of the most expensive mistakes in technical SEO, and getting it right is one of the highest-return tasks on a new site launch.
This guide covers what robots.txt actually controls, the five most common mistakes that block pages by accident, a safe template you can adapt, and how to test changes before they reach production.
Robots.Txt Seo: What Robots.txt for SEO Actually Controls
Robots.txt is a plain text file at the root of your domain (yoursite.com/robots.txt) that tells crawlers which URLs they can and cannot fetch. The file uses two main directives: User-agent (which crawler the rule applies to) and Disallow (which paths the crawler should skip). A third directive, Allow, lets you carve exceptions out of broader Disallow rules.
The critical thing to understand is what robots.txt does and doesn’t do. It blocks crawling, not indexing. A page that’s blocked in robots.txt can still appear in Google’s index if other sites link to it, because Google can index URLs without ever crawling the page contents. The result is an “indexed though blocked” warning in Search Console and a search snippet that just shows the URL with no description.
If you want to keep a page out of Google’s index, the right tool is a noindex meta tag inside the page’s HTML, not robots.txt. Robots.txt should be reserved for managing crawl budget, blocking scrapers, and keeping crawlers out of areas of the site (like admin paths or filtered URLs) that waste resources without providing search value.
Google ignores any robots.txt file larger than 500 KB. The vast majority of sites will never approach that limit, but if yours has thousands of lines of rules, you’ve likely got a deeper architecture problem worth solving instead.
The Five Most Common Mistakes
These five patterns cause the majority of robots.txt incidents I’ve seen across 60+ technical audits in the last two years.
1. Blocking the entire site by accident. A single line like “Disallow: /” tells every crawler to stay out of the entire domain. This usually happens when staging environments get pushed to production with the staging robots.txt intact. Always check robots.txt as the first step after any deploy.
2. Blocking CSS and JavaScript. Older SEO advice suggested blocking /wp-content/ or /assets/ to “save crawl budget.” Google now needs to render your pages to evaluate them, which means it needs to fetch the CSS and JS files. Blocking these makes your pages render incorrectly to Googlebot and triggers ranking drops. Open Search Console > URL Inspection > Test Live URL on any blocked page and you’ll see the broken render.
3. Using robots.txt to “noindex” pages. As covered above, blocking in robots.txt does not remove pages from the index. Pages that need to stay out of search results need a noindex meta tag, and that meta tag needs to be reachable, which means the page must be crawlable. Don’t combine noindex with a robots.txt Disallow on the same path.
4. Forgetting to update after a site restructure. Robots.txt rules built around old URL patterns often outlive the patterns themselves. After a migration, audit every Disallow rule to confirm it still references real paths.
5. Blocking parameter URLs without a sitemap fix. Filtered or sorted URLs (like /shop?color=blue&sort=price) can waste crawl budget on duplicate content. Blocking the parameter pattern is fine, but if your XML sitemap still includes the parametered versions, Google sees a contradiction and may distrust the entire sitemap.
A Safe Robots.txt Template You Can Adapt
Here’s a robots.txt template that works for most WordPress sites without blocking anything important. Adapt the disallowed paths to match your CMS, but keep the structure.
Standard WordPress robots.txt:
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /?s=
Disallow: /search/
Disallow: /wp-login.php
Sitemap: https://yoursite.com/sitemap.xml
What each line does:
- User-agent: * applies the rules to every crawler.
- Disallow: /wp-admin/ keeps crawlers out of the admin area, which has no search value.
- Allow: /wp-admin/admin-ajax.php carves out the AJAX endpoint that some plugins need accessible for proper page rendering.
- Disallow: /?s= and Disallow: /search/ prevent indexing of internal search-results pages, which create thin and duplicate content.
- Disallow: /wp-login.php blocks crawl of the login page.
- Sitemap: declares the canonical XML sitemap location to help crawlers discover your URLs faster.
Notice what’s not in this template. No blocking of /wp-content/, /wp-includes/, /uploads/, or any directory that contains CSS, JavaScript, or images. Those resources need to remain crawlable for Google to render your pages correctly.
For e-commerce sites, add Disallow rules for cart, checkout, and account paths. For multilingual sites, list a sitemap line for each language version. Keep the file under 50 lines. If you need more rules than that, you likely have a structural issue better solved with canonicals or noindex tags.
How to Test Robots.txt Before You Push It
Never edit robots.txt for SEO directly in production without testing. The downside risk is too large.
The standard tools for testing:
Google Search Console robots.txt report. Found under Settings in the new Search Console interface. It shows you the live robots.txt as Google sees it, when it was last fetched, and any parsing errors. Always check this first when troubleshooting a blocked-page issue.
Live URL inspection. In Search Console, paste any URL into the search bar at the top, click Test Live URL, and check whether Googlebot can fetch the page. If a page you didn’t intend to block shows as blocked by robots.txt, you’ll catch it here.
Command-line check. A quick curl or wget request to yoursite.com/robots.txt confirms what’s actually live. The file Google sees may differ from what your CMS displays in the dashboard if a CDN or plugin is rewriting it.
Staging site discipline. Maintain separate robots.txt files for staging and production environments and gate the deploy script to use the right file based on the target environment. The single most common cause of catastrophic robots.txt mistakes is staging files leaking to production.
Audit your robots.txt this week using the Search Console report and the template above. A 20-minute review now will save you the panic of explaining a deindexation incident later.

