What is a robots.txt file?
Short answer
robots.txt is a plain-text file at the root of a site (/robots.txt) that tells crawlers which paths they may or may not fetch. It uses User-agent, Disallow, Allow, and Sitemap directives, and it is advisory — not access control.
A map of what crawlers may fetch
robots.txt is the first place well-behaved crawlers look when they visit a site. It lists rules that say which URL paths a given crawler is allowed to request, so you can keep bots out of admin pages, search results, or duplicate URLs.
User-agent: *
Disallow: /admin
Disallow: /cart
Sitemap: https://example.com/sitemap.xmlWhere it goes
The file must live at the root of the domain, at https://example.com/robots.txt, and be served as plain text. A robots.txt in a subfolder is ignored.
Core directives
User-agent— which crawler the following rules apply to (*means all)Disallow— a path the crawler must not fetch; an empty value allows everythingAllow— a path that overrides a broader Disallow (honored by Google and Bing)Sitemap— the absolute URL of a sitemap; it applies site-wideCrawl-delay— seconds between requests (Bing and Yandex; Google ignores it)