Robots.txt Explained: Complete Guide with Examples

Santaji GadeSEOTechnical SEO2 weeks ago36 Views

robots.txt

Robots.txt is a plain-text file that controls billions of dollars of traffic daily. Here's the complete syntax, real 2026 AI crawler blocking rules (GPTBot, ClaudeBot), wildcard patterns, and a rule tester to check your own directives.

Technical SEO Robots.txt Crawling AI Crawlers

A single misplaced line in robots.txt can hide your entire site from Google. It is one of the smallest, oldest files on the web, plain text, four main directives, and it still controls billions of dollars of traffic every single day. This guide covers the full syntax, real AI crawler rules for 2026, and the one mistake that quietly de-indexes sites.

Robots.txt is a plain-text file placed at the root of a website that tells search engine crawlers and AI bots which URLs they are allowed or not allowed to access.

It follows the Robots Exclusion Protocol, formalized as RFC 9309, a standard respected by Google, Bing, and most major AI crawlers.

Advertisement
Advertisement

We covered the page-level counterpart to this file in our meta robots tags guide. Robots.txt blocks crawling before a page is ever fetched; meta robots tags control indexing after it already has been.

500KB

is Google's documented size limit for a robots.txt file; content beyond it is ignored

4

core directives cover nearly everything: User-agent, Disallow, Allow, Sitemap

2022

the year the Robots Exclusion Protocol became an official standard, RFC 9309

Basic Robots.txt Syntax

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

Sitemap: https://www.example.com/sitemap.xml

Must live at exactly yoursite.com/robots.txt; a file at /blog/robots.txt is simply ignored

Critical Distinction

Disallow is not noindex. Blocking a URL in robots.txt only stops crawling. If other sites link to that URL, it can still appear in search results, just without a title or description, since Google never fetched the page to read a noindex tag.

The Four Core Directives

DirectiveWhat It Does
User-agentSpecifies which crawler the following rules apply to
DisallowBlocks crawling of a specific path; empty value means allow everything
AllowCreates an exception inside a broader Disallow rule
SitemapPoints crawlers to your sitemap location; can appear anywhere, applies globally

Wildcard Patterns for Precise Matching

According to Ixieverse's complete robots.txt setup guide, combining the asterisk and dollar sign builds precise patterns matching specific URL structures rather than entire directories.

# Block every PDF file across the entire site
Disallow: /*.pdf$

# Block any URL containing a query string starting with ?sort=
Disallow: /*?sort=

# Block an entire path and everything beneath it
Disallow: /search

The dollar sign anchors the match to the end of the URL; without it, the pattern matches anywhere

Blocking or Allowing AI Crawlers in 2026

According to ToolsDock's complete 2026 robots.txt guide, every major AI company now runs its own crawler, some for training data, some for real-time browsing, and some for both.

# Allow Google and Bing as normal
User-agent: Googlebot
Allow: /

# Block OpenAI's training crawler specifically
User-agent: GPTBot
Disallow: /

# Allow Anthropic's on-demand fetch bot, block its training crawler
User-agent: Claude-User
Allow: /
User-agent: ClaudeBot
Disallow: /

Different bots from the same company often serve different purposes; block selectively, not all at once

Advertisement
Advertisement

Should You Block AI Crawlers Entirely?

This depends entirely on your goals. Tap through both perspectives.

Concerns about content being used for AI training without compensation, or protecting a paywalled business model, are valid reasons some publishers block AI training crawlers specifically.

Blocking search-oriented AI crawlers reduces visibility in ChatGPT, Perplexity, and AI Overviews, channels increasingly driving real referral traffic for many sites.

Robots.txt Rule Tester

Enter a Disallow pattern and a URL path to see if the rule would block it.

Robots.txt Rule Tester

Supports basic wildcard (*) and end-anchor ($) matching

Enter a pattern and URL, then click Test Rule.

Robots.txt and Crawl Budget

According to Conductor's guide to robots.txt essential rules, one incorrect rule can block major sections of a site from search engines and AI bots simultaneously, making careful review essential before any change goes live.

Directives only apply to the exact domain and protocol where the file is hosted, meaning http and https versions of the same site need matching files if both are technically reachable.

How Robots.txt Groups and Multiple User-Agents Work

According to InstarankSEO's complete 2026 robots.txt guide, a crawler looks for its specific User-agent block first, and falls back to the wildcard block only if no matching specific entry exists.

Multiple user-agents can also share the exact same set of rules, listed as consecutive User-agent lines followed by one shared block of directives, avoiding the need to repeat identical rules for each bot separately.

Common Mistakes That Break Robots.txt

MistakeWhat Happens
Disallow: / left in from stagingBlocks the entire live site from every crawler
Blocking CSS or JS directoriesGoogle can't render the page properly to evaluate it
Using robots.txt to hide indexed pagesDoesn't remove them; use noindex on the page instead
File placed anywhere but the rootIgnored entirely; must be at yoursite.com/robots.txt exactly
Relying on Crawl-delay for GooglebotGoogle ignores this directive completely

Testing Your Robots.txt Before Deploying

According to SE Ranking's robots.txt syntax and setup guide, a bot can technically choose not to obey the file at all, though major search engines and reputable AI crawlers do respect it in practice.

According to DominateTools' complete 2026 reference guide, testing changes in Google Search Console's report before deploying catches accidental blocks before they affect live crawling.

According to Fieldari's guide to examples, rules, and mistakes, the gap between what this file does and what it doesn't do is exactly where even experienced developers trip up, making a test pass before publishing a genuinely worthwhile habit.

According to ValidateHTML's complete syntax reference, running the final file through a dedicated syntax checker catches typos and malformed directives a quick manual read-through can easily miss.

Advertisement
Advertisement

FAQs on Robots.txt

Does robots.txt prevent a page from being indexed?
No. It only prevents crawling. A blocked page can still appear in search results without a description if other sites link to it. Use a noindex meta tag to actually prevent indexing.
Where must the robots.txt file be located?
At the exact root of the domain, such as https://www.example.com/robots.txt. A file placed in any subfolder is ignored entirely by crawlers.
Is robots.txt case-sensitive?
Path values are case-sensitive, so Disallow: /Admin/ differs from Disallow: /admin/. Directive names themselves, like User-agent and Disallow, are case-insensitive.
Can I block specific AI crawlers while allowing Google?
Yes. Create a separate User-agent block for each bot you want to treat differently, such as disallowing GPTBot while allowing Googlebot full access.
Does Google support the Crawl-delay directive?
No. Googlebot ignores Crawl-delay entirely, though some other crawlers, including Bingbot, do honor it.
What's the maximum size for a robots.txt file?
Google's documented limit is 500 kilobytes. Content beyond that limit is ignored, though most legitimate sites stay well under 1 kilobyte in practice.

> what_we_learn_today.log

[OK]

Robots.txt controls crawling; it never guarantees a page stays out of the index

[OK]

Four directives cover almost everything: User-agent, Disallow, Allow, Sitemap

[OK]

The file must live at the exact domain root, nowhere else

[OK]

Wildcard and end-anchor patterns allow precise, targeted rules

[OK]

Different AI crawlers can be allowed or blocked selectively per bot

[OK]

Always test changes before deploying; one bad line can block an entire site

0 Votes: 0 Upvotes, 0 Downvotes (0 Points)

Leave a reply

Loading Next Post...
Search
Popular Now
Loading

Signing-in 3 seconds...

Signing-up 3 seconds...