User-agent
User-agent: <crawler-token>Required at the start of a rule group. It identifies the crawler the following rules apply to. Use * for every crawler. Add consecutive User-agent lines to target several crawlers with the same rules.
Syntax
The complete grammar, matching behavior, and compatibility details for writing a valid robots.txt file.
https://example.com/robots.txt.field: value line.#, or text after #, is a comment. A UTF-8 byte-order mark at the beginning is ignored.# Global rules User-agent: * Disallow: /private/ Allow: /private/public/ Sitemap: https://example.com/sitemap.xml
User-agent: <crawler-token>Required at the start of a rule group. It identifies the crawler the following rules apply to. Use * for every crawler. Add consecutive User-agent lines to target several crawlers with the same rules.
Disallow: <path-pattern>Prevents crawling of matching paths for the current group. The value normally begins with /. An empty value means that nothing is blocked.
Allow: <path-pattern>Permits a matching path inside a broader Disallow rule. When matching Allow and Disallow patterns are equally specific, Allow wins.
Sitemap: <absolute-URL>Declares a sitemap using a fully qualified URL. It is independent of user-agent groups, can appear anywhere, and may be repeated for multiple sitemaps.
A group begins with one or more consecutive User-agent lines followed by its Allow and Disallow rules. A new User-agent after rules starts a new group.
The crawler selects the group with the most specific matching user-agent token. The wildcard group is used only when no more specific group matches. Groups with the same user-agent token may be combined by crawlers.
For a URL, the matching rule with the longest path wins. If equally specific Allow and Disallow rules both match, Allow wins. File order does not decide the result. With no matching rule, crawling is allowed.
User-agent: Googlebot User-agent: Bingbot Disallow: /search/ Allow: /search/help/ User-agent: * Disallow: /private/
Patterns match from the beginning of the URL path, including parameters and the query string. They do not include the scheme or host.
* matches any sequence of characters, including none.$ at the end of a pattern anchors the match to the end of the URL.| Pattern | Matches |
|---|---|
| / | Every URL on the host |
| /admin/ | Any path beginning with /admin/ |
| /private$ | Exactly /private; $ anchors the match to the end |
| /*.pdf$ | Any URL ending in .pdf; * matches zero or more characters |
| /search?* | Paths beginning with /search?; the query string is included |
| /file%20name | A URL containing the percent-encoded space in that path |
These extensions are not part of the standard Robots Exclusion Protocol. Unsupported crawlers ignore them.
Crawl-delay: 10Supported by Bing and some other crawlers; ignored by Google.
Request-rate: 1/10Requests one visit per ten seconds; support is limited and crawler-specific.
Host: www.example.comLegacy preferred-host hint used by some crawlers; ignored by Google and Bing.
# Rules for major search crawlers User-agent: Googlebot User-agent: Bingbot Disallow: /account/ Disallow: /search?* Allow: /account/help/ # Rules for every other crawler User-agent: * Disallow: /private/ Disallow: /*.pdf$ Allow: /private/public.pdf$ # Sitemap declarations are global Sitemap: https://example.com/sitemap.xml Sitemap: https://example.com/news-sitemap.xml
FAQ
Quick clarification for the syntax details that most often cause confusion.