📖 The Complete Guide to Robots.txt: Search Engine Specifications and SEO Advice
Learn more about how robots.txt works and best practices
Function introduction
Robots.txt Generator is a free online robots.txt creation tool launched by ToolHub. You can add multiple groups in the graphical interface User-agent(Googlebot, Bingbot, Baiduspider, YandexBot, etc.), settings Allow / Disallow rules, announcements Sitemap, adjust Crawl-delay with Host, the corresponding robots.txt content is instantly generated on the right side, and verification of grammar, blocking range, and duplication rules is automatically performed. It has built-in 7 commonly used templates such as WordPress, Blog, and E-commerce, and you can complete the basic settings with one click.
What is robots.txt?
robots.txt It is the "crawler command file" of the website, located in the root directory of the website. It uses a standardized format to tell search engine crawlers which pages can be crawled and which pages should be avoided. it follows Robots Exclusion Protocol(REP), is the basic link of SEO technical optimization.
A typical robots.txt consists of one or more "rule groups", each group contains User-agent corresponding to Allow / Disallow Rules:
User-agent: *
Disallow: /admin/
Disallow: /private/
Allow: /images/
Sitemap: https://example.com/sitemap.xml
How to use robots.txt?
Rule group (User-agent)
Each rule group starts with User-agent: At the beginning, specify the crawler to which the rule applies. General rules for use * Indicates all crawlers; you can also set exclusive rules for specific crawlers (such as Googlebot). Please note:Google only uses the first matching User-agent group, so the most specific crawler rules should be placed first.
Allow and Disallow
Disallow Block the specified path,Allow Open the specified path (Google natively supports Allow). Path must begin with a slash / Beginning, for example Disallow: /admin/. When Allow and Disallow exist at the same time,The longest matching path rule takes precedence——This is the basis for "blocking large areas first and then opening subdirectories".
Sitemap declaration
Sitemap: The directive tells the crawler the location of the XML Sitemap. This command has nothing to do with User-agent. It is usually placed at the end of the file and can declare multiple transactions. It is recommended that all websites declare a Sitemap in robots.txt.
Crawl-delay and Host
Crawl-delay Set the number of seconds between crawler requests (not supported by Google);Host Declare primary domain (supported by Yandex to avoid duplicate indexing of IP domains).
Common mistakes and how to avoid them
- Block entire site — used alone
Disallow: / This will make the entire site unindexable, which is the most impactful error. Be sure to check if it was intentional
- Path format error — Missing leading slash (
Disallow: admin/) or use a URL instead of a path (Disallow: https://…) are common mistakes
- Mixed case — Instruction names must be lowercase (
user-agent、disallow), the value is case-sensitive
- Repeat and Conflict Rules — Repeated declaration of the same path will cause maintenance difficulties; the latter is invalid when the User-agent group with the same name is repeated
- Misuse of robots.txt for security protection — It is just a protocol, not a firewall. Sensitive pages should use verification mechanisms
SEO advice
- Block but remain indexable — Blocking should not appear on functional pages of search results (shopping cart, account, admin) rather than on important content pages
- Be sure to declare your Sitemap — Let the crawler immediately know the content map every time it visits
- Avoid blocking CSS/JS — In modern SEO, blocking CSS/JS files prevents Google from understanding the page rendering results
- Verify after modification — Use Search Console’s robots.txt testing tool to confirm after deployment
- keep it simple — robots.txt should be concise and clear, overly complex rules are prone to errors
Browser compatibility
This tool is developed based on modern web standards and is compatible with the latest versions of all major browsers: Google Chrome, Mozilla Firefox, Apple Safari, Microsoft Edge and Opera. It is recommended to use the latest version for the best experience.
Privacy protection
ToolHub takes the privacy of your data seriously. Robots.txt Generator adopted 100% pure front-end architecture, all rule generation and verification are completed in your browser, and no data will be transmitted to external servers. We will not store, analyze or share any rule content you enter, please feel free to use it.