Why Declare Your XML Sitemap in Robots.txt?
While webmasters commonly submit sitemaps directly through Google Search Console and Bing Webmaster Tools, declaring your XML sitemap in robots.txt provides a universal, platform-agnostic discovery beacon. Every search engine crawler, regional search engine (such as Yandex or Baidu), and SEO audit tool reads robots.txt before beginning a crawl.
By including your sitemap declaration, you ensure that new canonical URLs are discovered immediately without requiring manual submission to every search console portal.
The Correct Sitemap Syntax
The sitemap directive is remarkably straightforward, but strict rules govern its placement and formatting:
Sitemap: https://example.com/sitemap.xml
Key Syntax Rules:
- Absolute URL Required: The sitemap path must be a complete, absolute URL including protocol (
https://) and domain. Relative paths likeSitemap: /sitemap.xmlare invalid and will be ignored. - Independent of User-Agent: The Sitemap directive applies globally to all crawlers. It does not belong to any specific
User-agentblock and can appear anywhere in the file (conventionally at the very top or very bottom). - Case-Insensitive Directive: Both
Sitemap:andsitemap:are recognized, though using standard Title Case is recommended.
Declaring Multiple Sitemaps and Sitemap Indexes
For large websites with tens of thousands of URLs, sitemaps are typically split into multiple files (each containing no more than 50,000 URLs or 50MB uncompressed) managed by a Sitemap Index file.
You have two compliant options for declaring multiple sitemaps:
Option A: Reference the Sitemap Index (Recommended)
User-agent: *
Disallow: /admin/
Sitemap: https://example.com/sitemap_index.xml
Search engines will fetch the index file and automatically discover all child sitemaps listed inside.
Option B: Declare Multiple Individual Sitemap Directives
User-agent: *
Disallow: /admin/
Sitemap: https://example.com/sitemap-posts.xml
Sitemap: https://example.com/sitemap-categories.xml
Sitemap: https://example.com/sitemap-products.xml
RFC 9309 and search engine standards permit multiple Sitemap: lines in a single robots.txt file.
Critical Distinction: Sitemaps Do Not Grant Crawl Access
If a page is listed in your XML sitemap but blocked by a Disallow directive, Googlebot will not crawl the page. In fact, Google Search Console will flag this condition as an error: "Submitted URL blocked by robots.txt." Always verify that your sitemap URLs are crawlable using our Bulk Robots.txt Tester.
Frequently Asked Questions
Where should I put the Sitemap line in robots.txt?
Conventionally, place it at the very bottom of the file after all User-agent blocks, separated by a blank line.
Can I put compressed (.xml.gz) sitemaps in robots.txt?
Yes. Search engines fully support gzip-compressed sitemaps (e.g., Sitemap: https://example.com/sitemap.xml.gz).
Does robots.txt sitemap declaration replace Google Search Console submission?
No. While robots.txt provides universal discovery, submitting via Google Search Console provides valuable indexing reports, error alerts, and crawl statistics.