What is robots.txt?

robots.txt is a text file at a site's root that tells web crawlers which paths they may or may not access.

robots.txt is a plain-text file placed at the root of a domain - at example.com/robots.txt - that communicates crawling rules to automated bots. Following the Robots Exclusion Protocol, it lists user-agent groups and the paths each is allowed or disallowed from fetching. Well-behaved crawlers, including major search engines, read this file before crawling and respect its directives.

The file's syntax revolves around a few directives: User-agent names which bot a block applies to (with an asterisk for all bots), Disallow blocks access to a path, and Allow carves out exceptions within a disallowed path. Many sites also include a Sitemap directive pointing crawlers to their XML sitemap, helping search engines discover URLs efficiently.

A crucial and frequently misunderstood point is that robots.txt controls crawling, not indexing. Disallowing a URL stops compliant crawlers from fetching it, but if that URL is linked elsewhere, it can still appear in search results without a description. To keep a page out of the index, use a noindex meta tag or header on a page that is crawlable - not a robots.txt block.

robots.txt is also the tool for managing crawl budget on large sites, steering crawlers away from low-value areas like faceted search results, internal search pages, or admin sections so they spend their crawl allocation on pages that matter. Because a single wrong Disallow line can hide an entire site from search, testing rules before deploying is essential.

Examples

  • User-agent: *\nDisallow: /admin/ - blocks all bots from the admin area
  • Sitemap: https://example.com/sitemap.xml - points crawlers to the sitemap
  • Disallow: /*?* - discourages crawling of parameterized URLs

Common questions

Does robots.txt keep a page out of Google?
No. It only asks crawlers not to fetch the page. A disallowed URL can still be indexed if linked from elsewhere. To exclude a page from the index, allow crawling and add a noindex directive.
Where must the robots.txt file be located?
At the root of the domain, exactly at /robots.txt. Crawlers only look there; a file placed in a subdirectory will not be recognized.
Do all bots obey robots.txt?
Only well-behaved ones. Reputable search engines respect it, but malicious scrapers and spam bots often ignore it entirely, so it is not a security or access-control mechanism.

Related tools

Related terms for robots.txt