I built Oginify — a free OG image generator. 3x daily, no signup. Try it →

SEO

robots.txt: Definition, Syntax & Best Practices

Explore robots.txt: definition, syntax, best practices. Crawl budget, resource protection, AI crawler management. Learn creative use cases. Free guide.

·Updated June 9, 2026·8 min read

What Is a robots.txt File?

robots.txt (also called the Robots Exclusion Protocol) is a plain text file placed in your website's root directory — for example, alignify.co/robots.txt`. It tells search engine crawlers which parts of your site they may or may not visit.

The file uses a straightforward directive format: you name a User-agent` (the crawler you're addressing), then list paths to Disallow` or Allow`. A robots.txt file is publicly accessible — anyone can view it by visiting yoursite.com/robots.txt`.

It's important to understand what robots.txt does not do: it does not prevent indexing (use `noindex` meta tags for that), it does not enforce security (it's a request, not a firewall), and not all crawlers honor it (malicious bots will ignore it entirely).

Core Functions of robots.txt

A well-written robots.txt serves three main purposes on a modern website.

1. Optimize Crawl Budget {#}

Search engines allocate a limited crawl budget to each site — the number of pages they'll crawl in a given timeframe. For larger sites (thousands of pages or more), robots.txt lets you direct that budget toward your most important content by blocking low-value URLs:

  • E-commerce filter and sort parameter pages (?color=red&size=XL)
  • Internal search result pages (/search?q=keyword)
  • User account areas and shopping carts (/my-account/, /cart/)
  • Staging and development environments

2. Protect Sensitive Resources {#}

While robots.txt is not a security mechanism, it prevents well-behaved crawlers from wasting resources on areas that should not appear in search results: admin panels, API endpoints, internal scripts, and private directories.

3. Manage AI Crawlers {#}

The rise of large language models has introduced a new category of bots. Some crawl to build training datasets (GPTBot, ClaudeBot, Bytespider); others crawl to provide cited search results (OAI-SearchBot, PerplexityBot, Claude-User). robots.txt is currently the primary mechanism for declaring your preferences to both categories.

A growing number of sites distinguish between these two groups: allowing AI search/citation bots (which bring visibility and referral traffic) while disallowing AI training bots (which consume bandwidth without attribution).

robots.txt Syntax and Writing Standards

Every robots.txt file follows the same basic grammar. Understanding these rules prevents the most common configuration mistakes.

1. Basic Directives {#}

DirectivePurposeExample
User-agentSpecifies which crawler the rules apply toUser-agent: Googlebot
DisallowBlocks a path from crawlingDisallow: /private/
AllowCreates an exception within a blocked directoryAllow: /blog/public/
SitemapPoints to your XML sitemap locationSitemap: https://example.com/sitemap.xml

2. Pattern Matching {#}

  • wildcard: Matches any sequence of characters. Disallow: /tmp/ blocks everything under the /tmp/ directory.
  • $ end marker: Forces an exact match at the URL's end. Allow: /news/$ allows the directory listing but Allow: /news/*.html$ only allows .html files.

3. Priority Rules {#}

When multiple rules could apply to the same URL: more specific paths take precedence over general ones. Allow: /shop/shoes/` overrides Disallow: /shop/`. For the same path, the first matching rule in the file wins — so put specific Allow rules before broad Disallow rules.

Best Practices

These patterns represent what production-grade robots.txt files look like across well-maintained sites.

1. Use a Structured, Commented Format {#}

Group rules by purpose and add comments explaining why each section exists. A future maintainer (including you, six months later) should understand the reasoning without guessing.

# === Crawl budget: block low-value paths ===
User-agent: *
Disallow: /cart/
Disallow: /checkout/
Disallow: /my-account/

# === Allow blog content indexing === Allow: /blog/*.html$

# === Sitemap reference === Sitemap: https://example.com/sitemap.xml

2. Handle Multiple Subdomains Explicitly {#}

Each subdomain needs its own robots.txt at its root. For consistency across subdomains, some teams use a redirect to a central file: Redirect 301 /robots.txt https://cdn.example.com/robots.txt` Note: this only works if the central file uses path-relative rules that apply correctly to all subdomains.

3. Separate Rules by Crawler {#}

Different bots serve different purposes. A modern robots.txt typically has at least two User-agent blocks: one for traditional search engines (broad Allow) and one for AI training bots (broad Disallow). See the strategy guide below for decision frameworks.

Common Mistakes (and How to Avoid Them)

These errors appear frequently in production robots.txt files — even on large, well-known sites.

1. Blocking Critical Resources {#}

The mistake: Disallow: /css/` or Disallow: /js/` prevents crawlers from fetching stylesheets and scripts. Google uses these to understand page layout and mobile-friendliness — blocking them can hurt rankings.

The fix: Never block asset directories by default. If you need to hide specific resources, use more granular path patterns.

2. Using Absolute Urls {#}

The mistake: Disallow: https://example.com/private/` Why it fails: robots.txt directives use path-relative notation only. Absolute URLs are silently ignored by most parsers.

The fix: Always use relative paths: Disallow: /private/`.

3. Ignoring Case Sensitivity {#}

URL paths are case-sensitive. Disallow: /Admin/` does not block /admin/`. Always match the actual URL casing used by your server.

4. Forgetting to Update after Site Changes {#}

A robots.txt rule that blocked /old-blog/` two years ago may now be blocking your new blog if you repurposed that path. Audit your robots.txt whenever you restructure URLs or launch new site sections.

Advanced Application Scenarios

Beyond basic path blocking, robots.txt can handle more nuanced situations.

1. Dynamic Parameter Control {#}

For CMS-driven sites that generate URLs with query parameters (WordPress, Shopify, etc.), you can block parameter-heavy pages while allowing specific tracked parameters:

User-agent: 
Disallow: /?
Allow: /?utm_source
Allow: /?utm_medium
Allow: /*?ref

This allows marketing attribution links while blocking other dynamically-generated duplicate pages.

2. Crawler-Specific Rules {#}

Different search engines have different crawlers for different content types. You can target rules to specific ones:

# Allow news crawler to access press releases only
User-agent: Googlebot-News
Allow: /press-releases/
Disallow: /

# Block Image Crawler from Heavy Asset Directories User-agent: Googlebot-Image Disallow: /assets/originals/

3. Crawl-Delay Directive {#}

The Crawl-delay` directive requests a minimum delay (in seconds) between successive requests. Note: Google does not support this directive; it is primarily honored by Bing and Yandex. Crawl-delay: 10`

Validation and Debugging Tools

Before deploying changes to your live robots.txt, use these tools to catch errors.

1. Google Search Console robots.txt Tester {#}

Navigate to Settings → robots.txt in Google Search Console. The built-in tester highlights syntax errors, flags conflicting rules, and lets you test specific URLs against your rules before making them live. This is the single most important validation step.

2. Server Log Analysis {#}

Monitor your access logs to verify which crawlers are hitting your site and whether they're respecting your robots.txt rules. A typical Googlebot entry looks like:

66.249.66.1 - - [15/Jul/2024:12:34:56 +0000] "GET /blog/ HTTP/1.1" 200 4321 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

If you see a blocked user-agent accessing disallowed paths, verify your robots.txt syntax and check that your web server is serving it correctly (Content-Type: text/plain, HTTP 200).

3. Third-Party Crawl Tools {#}

Tools like Screaming Frog and Sitebulb can simulate how search engines interpret your robots.txt and identify pages that are accidentally blocked or exposed.

Real-World robots.txt Examples

Looking at how major sites structure their robots.txt can teach you more than any tutorial. Here are three that demonstrate different philosophies.

1. Google — Clean and Self-Referential {#}

Google's own robots.txt is famously minimal and well-commented. One of their most shared easter eggs references the Terminator films:

User-agent: T-800
User-agent: T-1000
Disallow: /+LarryPage
Disallow: /+SergeyBrin

Beyond the humor, the real lesson is in the file's structure: clear comments explaining each section, grouped rules by crawler type, and a disciplined approach to only blocking what needs blocking.

2. Nike — Brand Identity in Configuration {#}

Nike extends its "Just Do It" philosophy into robots.txt with a playful comment. The more practical takeaway: their file is structured to protect product catalog pages while allowing marketing and brand content to be fully crawlable — a pattern relevant to any e-commerce site.

3. Wikipedia — Minimalist and Open {#}

Wikipedia's robots.txt takes the opposite approach from most commercial sites: it blocks almost nothing, relying on its internal linking structure and canonical tags to manage crawl efficiency. This demonstrates that for sites with naturally strong architecture, a minimal robots.txt is often the best choice.

How to Choose Your robots.txt Strategy

There is no one-size-fits-all robots.txt. Your strategy depends on your site's size, content type, and goals. Use this decision framework to build yours.

Small Sites (< 50 Pages): Keep It Minimal {#}

If your site has fewer than 50 pages with strong internal linking, you likely do not need complex robots.txt rules. A minimal file with just a sitemap reference is often sufficient:

Sitemap: https://yoursite.com/sitemap.xml

Add Disallow rules only if you have specific pages that should not appear in search results (admin panels, thank-you pages, internal tools).

Content Sites and Blogs: Focus on AI Bot Policy {#}

For content-driven sites, the biggest robots.txt decision in 2024–2025 is your AI crawler policy. A common approach:

  • Allow AI search/citation bots (OAI-SearchBot, PerplexityBot, Claude-User): These bring visibility and referral traffic when your content appears in AI-generated answers with citations.
  • Disallow AI training bots (GPTBot, ClaudeBot, Bytespider): These scrape your content for model training without sending traffic back.

Whether to also disallow Google-Extended (which controls use in Google's AI products) depends on your content strategy — if you rely on Google Discover or AI Overviews for traffic, blocking it may be counterproductive.

E-Commerce Sites: Prioritize Crawl Budget {#}

For product catalogs with hundreds or thousands of SKUs, crawl budget is your primary concern. Block faceted navigation, internal search, sorting parameters, and session IDs. Allow product pages, category pages, and your blog. Review your parameter list quarterly against your analytics to ensure you're not accidentally blocking newly important sections.

SaaS and Web Apps: Protect Gated Resources {#}

SaaS sites typically have a public-facing marketing site and a gated application. Your robots.txt should block the app's internal routes (dashboards, settings, API docs) while keeping marketing pages fully crawlable. If your app and marketing site share a domain, this separation in robots.txt is essential.

Conclusion

robots.txt is deceptively simple — a few lines of text that control how the entire web sees your site. The rules are straightforward, but the consequences of getting them wrong can be severe: pages disappearing from search results, crawl budget wasted on duplicate content, or AI training bots scraping your work without permission.

The most effective approach is to treat your robots.txt as living documentation. Audit it quarterly, test changes in Google Search Console before deploying, and keep it aligned with your site's actual URL structure. A robots.txt that was perfect six months ago may be silently breaking your SEO today if new sections have been added that fall under old Disallow rules.

Quick action checklist:

  1. Run your current robots.txt through Google Search Console's tester
  2. Verify your sitemap URL is declared
  3. Check that no Disallow rules accidentally cover new site sections
  4. Review your AI bot policy against your current content strategy
  5. After any changes, submit the updated robots.txt in GSC

References

  1. Introduction to robots.txt (Google Search Central · Updated regularly)Google's official guide to robots.txt syntax, usage, and best practices.
  2. How To Create a Robots.txt File (Bing Webmaster Tools · 2026)Bing's guide to creating and configuring robots.txt files for search engine crawlers.
  3. Robots.txt and SEO: Everything You Need to Know (Search Engine Journal · 2026)Comprehensive guide to robots.txt configuration for SEO, covering syntax, directives, and common pitfalls.

Let It Crawl What You Want Seen.

robots.txt is your doorman's agreement with crawlers. Get it right and your crawl budget goes where it counts.

Get help

This site uses cookies and similar technologies for analytics, personalized ads (via Google AdSense), and essential functions. By clicking “Accept All”, you consent to our use of cookies. You can reject non-essential cookies by clicking “Reject All”.

Privacy Policy