Skip to content

robots.txt Rules Explained: User-agent, Disallow and Allow

Up to date as of 1 December 2026

Every robots.txt file is built from groups of lines. Each group names a crawler, then lists what it may and may not visit. Learn one group and you can read the whole file.

The first line: User-agent

A group begins with a User-agent line that specifies the target of the group.1

"User agent" is the name a crawler goes by. Googlebot is Google's main one.

Using an asterisk matches all crawlers, apart from the various AdsBot crawlers, which must be named directly.1 So this line means "everyone":

User-agent: *

Disallow: where not to go

A Disallow line names a directory or page that the crawler shouldn't visit. The path must start with a / character, and a directory should end with one too.1

User-agent: *
Disallow: /drafts/

This asks every crawler to stay out of the drafts folder.

How one group of rules is builtUser-agent: who the rules are forDisallow: paths to stay out ofAllow: exceptions inside those pathsCrawler follows the most specific match
Each group starts by naming who it's for.

Allow: exceptions

Allow does the reverse. It lets a crawler visit a page or folder inside a place you've otherwise blocked. Google describes it as a way to override a disallow rule for a subdirectory or page in a disallowed directory.1

User-agent: *
Disallow: /drafts/
Allow: /drafts/open-day.html

Here the drafts folder is off limits, except one page.

Which rule wins

When rules overlap, the standard says the most specific match is used.2 The most specific match is the one with the most characters in it. In the example above, the page rule is longer, so it wins for that one page.2

What happens with no rule

Google says the default assumption is that a user agent can crawl any page or directory not blocked by a Disallow rule.1 The standard agrees: if no match is found in a group for a matching user-agent, the address is allowed.2

So you only write rules for the places you want to ask crawlers to skip.

Small details that trip people up

  • Rules are case-sensitive. A rule for /file.asp applies to that address but not to /FILE.asp.1
  • A # character starts a comment, which crawlers ignore. Use comments to leave yourself notes.1
  • Each rule gets its own line, with one rule per line.1

Naming a crawler or several

You can write a group for one crawler by its name, and another group for everyone else. A crawler can match only one group, the first and most specific one that fits it.1 Respectable crawlers follow the rules, but each crawler may read the syntax a little differently.3

Also remember the file asks. It doesn't enforce.

Where to go next

Not sure the file is in the right spot? The page on file location covers that. To see why a blocked page can still show up, read about blocked pages that appear anyway.

Cited material

  1. Create and Submit a robots.txt File, Google Search Central
  2. RFC 9309: Robots Exclusion Protocol, IETF
  3. Robots.txt Introduction and Guide, Google Search Central