robots.txt & Crawl Control Guide for SEO

robots.txt gives cooperative crawlers instructions about which URL paths they may crawl. It is not authentication, a privacy control or a reliable way to remove indexed URLs. Use it carefully and test crawler-specific behavior.

What robots.txt Does (and Doesn't Do)

robots.txt controls crawling, not indexing. This is the most misunderstood aspect of robots.txt and the source of most mistakes.

  • Crawling = a search engine bot visiting and downloading a page's content.
  • Indexing = a search engine adding a page to its search results database.

When you block a URL via robots.txt, you prevent the bot from reading the page. But if other websites link to that page, Google may still index the URL — it just won't have any content to show, resulting in a listing that says "No information is available for this page." To truly prevent indexing, use a noindex robots meta tag on the page itself.

Critical rule: If you want a page to be noindexed, do NOT block it in robots.txt. The bot must be able to crawl the page to see the noindex directive.

robots.txt Syntax

The file uses a simple directive-based syntax. Here are the core directives:

DirectivePurposeExample
User-agentSpecifies which bot the rules apply toUser-agent: Googlebot
DisallowBlocks a path from being crawledDisallow: /admin/
AllowOverrides a Disallow for a specific sub-pathAllow: /admin/public/
SitemapPoints to an XML sitemapSitemap: https://example.com/sitemap.xml
Crawl-delaySeconds between requests (Bing respects, Google ignores)Crawl-delay: 10

Wildcard patterns: Use * to match any sequence of characters and $ to match the end of a URL. For example, Disallow: /*.pdf$ blocks all PDF files across your entire site.

User-Agent Targeting

You can create different rule sets for different bots. Common user agents include:

  • * — matches all crawlers (the wildcard default).
  • Googlebot — Google's primary web crawler.
  • Bingbot — Microsoft Bing's crawler.
  • Googlebot-Image — Google's image crawler (block to prevent image indexing).
  • GPTBot — OpenAI's crawler for AI training data.
  • CCBot — Common Crawl's bot, often blocked by sites that don't want AI training scraping.

Google selects the most specific matching user-agent group and combines groups matching that same agent. A specific group does not inherit the wildcard group. Other crawlers may differ; test the intended crawler’s documented parsing rules.

Common robots.txt Examples

Allow everything (default if no robots.txt exists):

User-agent: *
Disallow:

Block a single directory:

User-agent: *
Disallow: /admin/
Disallow: /staging/

Block everything except one directory:

User-agent: *
Disallow: /
Allow: /public/

Block AI crawlers while allowing search engines:

User-agent: GPTBot
Disallow: /

User-agent: CCBot
Disallow: /

User-agent: *
Disallow: /admin/
Sitemap: https://example.com/sitemap.xml

Crawl Budget Optimization

Crawl budget matters primarily for very large sites (Google's guidance targets roughly 1 million+ pages, or 10,000+ pages that change daily). For smaller sites, Google generally crawls everything without issues. But for large sites, wasting crawl budget on low-value pages means important pages get crawled less frequently.

Pages to consider blocking:

  • Faceted navigation — filtering URLs like /shoes?color=red&size=10&sort=price can create millions of near-duplicate pages.
  • Internal search results — /search?q= pages generate infinite URL combinations.
  • Session/parameter URLs — URLs with session IDs, tracking parameters, or pagination beyond reasonable depth.
  • Print/PDF versions — duplicate content in alternative formats.
  • Protect private staging environments with authentication or network access controls. robots.txt is public and does not prevent access or guarantee exclusion from indexing.

Blocking vs Noindexing: When to Use Which

ScenarioUse robots.txt?Use noindex?Why
Private admin areaOptional crawl controlNot a confidentiality controlRequire authentication; robots.txt and noindex do not secure private content
Thin content pages you want de-indexedNoYesBot must see the noindex directive
Infinite faceted navigationYesOptionalPreserves crawl budget at scale
Pages with sensitive informationNoNoUse authentication — robots.txt is public
Duplicate content with canonical tagNoNoLet bot crawl, read canonical, and consolidate

Testing Your robots.txt

Always validate your robots.txt before deploying changes to production. A single syntax error can accidentally block your entire site.

  • Google Search Console — the robots.txt report shows files Google fetched and parsing information. URL Inspection’s indexed view describes the last indexed version; use the live test for current fetchability and inspect its reported crawl allowance. Neither view guarantees future indexing or instantaneous use of a newly deployed robots.txt file.
  • Manual testing — visit yourdomain.com/robots.txt in a browser and visually inspect the output. Confirm you can see the file, it returns a 200 status code, and the content-type is text/plain.
  • Staging first: Test rule changes before deployment and verify the live result. An accidental crawl block can disrupt crawling, but does not necessarily remove already indexed URLs or do so within a fixed time.

robots.txt & International Sites

For sites with multiple subdomains or country-code paths, keep these considerations in mind:

  • Each subdomain requires its own robots.txt — blog.example.com/robots.txt and shop.example.com/robots.txt are completely independent files.
  • Subdirectory-based internationalization (/en/, /fr/, /de/) shares a single root robots.txt. Define rules per path prefix: Disallow: /fr/admin/.
  • Include sitemap references for all language versions to ensure comprehensive crawling of international content.

Common Mistakes

  1. Blocking all crawling: Disallow: / in an applicable group can prevent cooperative crawling, but does not hide the site from all search results or protect access. Check deployment rules and use authentication for private content.
  2. Blocking CSS and JavaScript — Google needs to render pages to understand them. Blocking CSS/JS files prevents rendering, which hurts both indexing and rankings.
  3. Using robots.txt for security — robots.txt is publicly readable. Anyone can visit /robots.txt to see exactly which paths you're "hiding." Never rely on it for security.
  4. Conflicting with noindex — blocking a page in robots.txt AND adding noindex to it means the bot can't reach the page to see the noindex tag. The page might still get indexed via external links.
  5. Forgetting the trailing slash — Disallow: /directory blocks both /directory and /directory-other/. Add a trailing slash (Disallow: /directory/) to be more precise.
  6. Not including a Sitemap directive — while not required, pointing to your sitemap in robots.txt ensures crawlers can find it even if it's not submitted in Search Console.

Try It Yourself

Build a properly formatted robots.txt file with user-agent targeting, disallow rules, allow overrides, and sitemap references — ready to deploy.

robots.txt Generator →

Frequently Asked Questions

Robots.txt requests crawling restrictions, not guaranteed exclusion from indexing. A blocked URL can still appear in results. To use noindex, allow the crawler to access the directive; protect private content with authentication. Do not rely on a particular displayed snippet for blocked URLs.
Serve robots.txt at /robots.txt for the applicable scheme, host and port, normally as UTF-8 plain text with a successful response. Rules do not automatically cover other origins. A robots.txt file is optional; different error responses have different crawler consequences.
Yes, but with limitations. You can disallow specific paths like "Disallow: /private-page/" to block crawling of individual URLs. You can also use wildcards: "Disallow: /category/*/page/" blocks all paginated category pages. However, remember that blocking crawling doesn't prevent indexing. Protect sensitive pages with authentication. For public pages you want excluded from search, allow crawling so Google can read noindex; robots.txt blocking prevents that check. Remove nonindexable URLs from sitemaps too.
Crawl budget reflects crawl capacity and demand. It is mainly relevant to large, rapidly changing or demonstrably under-crawled sites, not a fixed page-count cutoff. Investigate crawl evidence and avoid blocking useful content or resources merely to meet a quota.
Use the current Search Console robots.txt report and URL Inspection to investigate retrieval and specific URLs. A local validator can check selected syntax but may not implement Google’s grouping and precedence rules or certify deployed behavior. Test representative URLs after changes.