EN
FRENCH
繁体中文
Robots.txt is a text file that tells web crawlers which parts of a website they are allowed or disallowed to access.
It follows the Robots Exclusion Protocol and is typically placed in the root directory of a website.
Website owners use robots.txt to manage crawler traffic, guide search engine bots, and reduce unnecessary requests to certain pages.
When a compliant web crawler visits a website, it can check the robots.txt file before requesting other resources.
The process typically involves:
Robots.txt is a voluntary protocol, so not every crawler follows its instructions.
| Directive | Purpose |
|---|---|
User-agent |
Specifies which crawlers a rule applies to |
Disallow |
Identifies paths crawlers should not access |
Allow |
Explicitly permits access to matching paths |
Sitemap |
Indicates the location of an XML sitemap |
For example:
User-agent: *
Disallow: /admin/
Disallow: /private/
Allow: /public/
The asterisk applies the rules to all crawlers that do not have a more specific matching group.
Both help website owners manage search engine behavior, but they serve different purposes.
Blocking a page in robots.txt does not guarantee that its URL will be excluded from search results.
Robots.txt and XML sitemaps are complementary tools.
A sitemap does not override restrictions defined in robots.txt.
Sensitive information should be protected with authentication and proper access controls.
Robots.txt is an important consideration when building web scraping applications.
Before collecting website data, developers should review the site's crawling instructions and applicable access requirements.
For example, if a website disallows access to a particular directory, a compliant scraper should avoid requesting pages within that path.
Robots.txt should be considered alongside website terms, authentication requirements, and reasonable request rates.
Suppose a website publishes the following robots.txt file:
User-agent: *
Disallow: /checkout/
Disallow: /account/
Allow: /products/
Sitemap: https://example.com/sitemap.xml
This configuration tells compliant crawlers to avoid checkout and account paths while allowing product pages.
It also identifies the website's XML sitemap to assist discovery.
Robots.txt is a website-level file that communicates crawling rules to automated bots.
It helps manage crawler access, reduce unnecessary traffic, and support SEO. However, it does not provide security or guarantee that pages will be removed from search results.
Partnership