Free website & SEO check: see your score in under a minute  ·  Check my website →Premium Windows software for marketers: talk to us for access and pricing  ·  Explore the software →
Fundamentals Updated May 22, 2026  ·  9 min read

What is Robots.txt? The Complete 2026 Guide for SEO & AI Bots

The first thing to learn about robots.txt is the thing most people get backwards: it controls crawling, not indexing. A page you "block" in robots.txt can still show up in Google as a bare link, because you told the bot not to read the page, not to forget it exists. Once that distinction clicks, every other robots.txt decision gets easier, including the newer 2026 one of whether OpenAI, Anthropic, and Google get to train on your content. This guide builds from that foundation up.

Quick verdict: Robots.txt is a plain text file at yoursite.com/robots.txt that tells crawlers which pages they may read. It manages crawl, not indexing (use noindex for that) and not privacy (use a password for that). Major search and AI bots respect it voluntarily. Use it for crawl budget, admin/duplicate paths, and AI-training opt-outs. Generate one in 30 seconds with our free generator.

How Robots.txt Actually Works

Every legitimate web crawler — Googlebot, Bingbot, the social media link previewers, the AI training crawlers — performs the same first action when it visits a new domain. Before crawling any page, it requests https://yoursite.com/robots.txt.

If the file exists, the bot reads it and applies the rules to its own user-agent. If it doesn't exist (HTTP 404), the bot assumes everything is allowed. If the file errors out (HTTP 500 or unreachable), Google specifically pauses crawling of your site entirely until it can fetch the file successfully — one reason a broken robots.txt is much worse than a missing one.

The file uses a simple text format defined by the Robots Exclusion Protocol (now formalized as RFC 9309 in 2022). Each rule block targets a specific bot or group of bots and lists which paths are allowed or disallowed.

The Syntax: Five Directives You Need to Know

DirectiveWhat it doesRequired?
User-agent:Specifies which bot the following rules apply to. Use * to target all bots.Yes
Disallow:Prevents the user-agent from crawling URLs matching this pattern.Optional
Allow:Overrides a previous Disallow to permit a specific path or sub-path.Optional
Sitemap:Points to your sitemap.xml URL. Helps crawlers discover your URL list.Recommended
Crawl-delay:Asks the bot to wait N seconds between requests. Google ignores this; Bing and Yandex respect it.Limited support
Directives must be capitalized exactly as shown. Lowercase or mixed case is ignored by some crawlers.

Real-World Examples

Allow everything (default behavior, but explicit)

User-agent: *
Allow: /

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

Every bot is allowed to crawl every path. Sitemap is provided for discovery. This is a perfectly valid baseline robots.txt.

Block admin paths from all bots

User-agent: *
Disallow: /admin/
Disallow: /wp-admin/
Disallow: /cart/
Disallow: /checkout/
Disallow: /?s=
Disallow: /search?

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

Blocks common admin, e-commerce checkout, and internal-search paths from all bots.

Block AI training bots, allow search engines

User-agent: GPTBot
Disallow: /

User-agent: ClaudeBot
Disallow: /

User-agent: Google-Extended
Disallow: /

User-agent: PerplexityBot
Disallow: /

User-agent: CCBot
Disallow: /

User-agent: *
Allow: /

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

AI training crawlers are blocked. Googlebot, Bingbot, and other search-engine crawlers continue normally. This pattern is increasingly common in 2026.

Allow Googlebot only, block everything else

User-agent: Googlebot
Allow: /

User-agent: *
Disallow: /

Aggressive setup — Googlebot crawls freely, every other bot (including Bing) is blocked entirely. Generally not recommended unless you have a strong reason.

The 2026 Question: AI Training Bots

The single biggest shift in robots.txt usage since 2023 is the rise of AI training crawlers. Every major AI company now operates a publicly-identified bot that respects robots.txt, giving website owners a choice about whether to participate in AI training data.

User-agentCompanyWhat they use it for
GPTBotOpenAITraining data for ChatGPT models
ChatGPT-UserOpenAIReal-time browsing when ChatGPT answers user questions
ClaudeBotAnthropicTraining data for Claude models
Google-ExtendedGoogleTraining data for Gemini (separate from Googlebot for search)
PerplexityBotPerplexityIndexing for Perplexity's AI search
CCBotCommon CrawlOpen-source web archive used as training data by many AI labs
anthropic-aiAnthropic (legacy)Older Anthropic crawler — still respected if listed
cohere-aiCohereTraining data for Cohere models
Block these individually in robots.txt to opt out of AI training. Note: blocking Google-Extended does NOT block Googlebot — you can still rank in Google Search while opting out of Gemini training.
Important nuance: blocking GPTBot stops OpenAI from training on your content. It does NOT stop ChatGPT from showing your existing content if it's already in training data or if a user pastes your URL into a conversation. Robots.txt is forward-looking only.

What Robots.txt Cannot Do

This is where most confusion lives. Robots.txt is not a security tool. It tells well-behaved bots what to do; it cannot prevent bad actors from accessing anything.

  • It can't hide content from indexing. Google can index pages from external links even when they're blocked in robots.txt. To prevent indexing, use a <meta name="robots" content="noindex"> tag in the page HTML.
  • It can't make pages private. Anyone can read your robots.txt, which actually reveals the paths you're trying to hide. Don't list sensitive admin URLs — you're publishing a map of what's worth attacking.
  • It can't stop scrapers. Malicious bots, AI scrapers operating without identifiable user-agents, and content thieves routinely ignore robots.txt. For protection, use authentication, IP blocking, or web application firewalls.
  • It can't remove content from Google. If a page is already indexed, blocking it in robots.txt actually prevents Google from re-crawling to see the removal — meaning the old listing stays in search results longer. Use Search Console's Remove URL tool or noindex tag instead.
  • It can't enforce rules. The entire protocol is voluntary. Compliance is a courtesy, not a guarantee.

When to Use Robots.txt vs Other Tools

GoalRight toolWhy
Prevent crawling of a pathDisallow: in robots.txtStops bots from fetching
Prevent indexing of a pagenoindex meta tagRobots.txt blocks crawling but not indexing
Protect sensitive dataAuthentication + access controlRobots.txt is public; bad actors ignore it
Manage crawl budgetDisallow: low-value pathsKeeps bots focused on important content
Opt out of AI trainingBlock AI user-agents in robots.txtVoluntary but respected by major AI companies
Speed up bot crawlingSitemap: directiveHelps bots discover all your URLs
Slow down aggressive crawlingCrawl-delay: (limited support)Bing/Yandex honor it; Google doesn't
Pick the right tool for each goal. Robots.txt is one piece of crawl management, not a security layer.

How to Test Your Robots.txt

  1. Visit it in a browser. Go to https://yoursite.com/robots.txt and confirm it loads. If it 404s, the bots won't find it.
  2. Use Google Search Console's robots.txt report. Settings → Robots.txt — shows what Google sees and flags any parse errors.
  3. Test specific URLs. Use Google's "URL Inspection" tool to confirm whether a given URL is blocked or allowed.
  4. Check Bing too. Bing Webmaster Tools has its own robots.txt tester — the behavior usually matches Google but not always.
  5. Monitor crawl errors. Watch Search Console's Crawl Stats for unexpected drops in crawl rate after publishing a new robots.txt.

Pattern Matching: The Wildcards That Trip People Up

Robots.txt supports limited pattern matching. Getting this slightly wrong is one of the most common ways to accidentally block important content.

  • * — matches any sequence of characters. Disallow: /*.pdf blocks all PDFs.
  • $ — matches the end of the URL. Disallow: /*.pdf$ blocks only URLs that end with .pdf (not /page.pdf?download=1).
  • Trailing slash matters. Disallow: /admin blocks both /admin and /admin-stuff. Disallow: /admin/ blocks only paths inside the /admin/ folder.
  • Case sensitivity. URLs are case-sensitive, so Disallow: /Admin/ doesn't block /admin/. Block both if needed.
  • Specificity wins. If multiple rules match a URL, the most specific rule applies. Allow: /admin/public/ overrides Disallow: /admin/ for any URL under /admin/public/.
From the classroom

The analogy I use to make the crawl-vs-index distinction stick: robots.txt is a "please don't come in" sign on a room's door, not a shredder for what's inside. If a bot honors the sign, it won't enter and read the room, but if a hundred other websites have a signpost pointing at that door ("the thing you want is in there"), Google will still list the door in its directory, it just can't describe what's inside. Students always assume the sign deletes the room. It doesn't. So the question I make them answer before choosing a tool is "do I want the bot to not read this, or to not list this?" Not read, robots.txt. Not list, noindex (which means the door has to stay open so the bot can see the noindex note inside). Get that one question right and you stop blocking pages you meant to hide and accidentally hiding pages you meant to keep.

Frequently Asked Questions

Technically no — if you want all bots to crawl everything, the default behavior with no robots.txt is identical. But practically yes: even a minimal "allow everything + sitemap" file gives you the sitemap discovery benefit and demonstrates the site is professionally managed.

Google enforces a 500KB limit; content beyond that is ignored. Bing is similar. In practice, most robots.txt files are under 5KB and there's no reason to ever approach the limit — if you need hundreds of rules, you're probably solving the wrong problem.

Yes — User-agent: * followed by Disallow: / blocks all compliant bots from crawling anything. This is sometimes used for staging sites or unfinished projects. Don't ship this to production — it removes your site from Google entirely within days.

Most bots cache robots.txt for up to 24 hours. Changes typically take 1-2 days to take effect across all bots. For urgent changes, use Search Console's robots.txt validation to force Google to re-fetch immediately.

Yes — staging sites should have User-agent: * / Disallow: / to prevent accidental indexing of incomplete work. Better: put staging behind HTTP authentication. The robots.txt approach relies on bots being well-behaved, while authentication actually enforces the block.

Yes — WordPress generates a virtual robots.txt automatically if no physical file exists. It blocks /wp-admin/ and a few system paths. For most sites this is too minimal — see our WordPress + Shopify robots.txt guide for the proper setup.

Crawl, not index, is the whole foundation

Robots.txt controls which bots crawl which pages, full stop. It is not an index-control tool (that's noindex) and not a privacy tool (that's a password). Once that distinction is clear, the rest is easy: use it for crawl-budget management, admin paths, and 2026's new question of whether AI services train on your content. It's voluntary but universally respected by the majors. Our free generator builds a correct robots.txt in 30 seconds, but understanding crawl-vs-index is what keeps you from misusing it.