How to Add a Sitemap to robots.txt Correctly
Add a standalone Sitemap line containing the full absolute URL of your XML sitemap or sitemap index, such as Sitemap: https://example.com/sitemap.xml. The line may appear anywhere in robots.txt and may be repeated, but it only helps discovery: it does not override Disallow rules or guarantee crawling or indexing.
Copy-paste robots.txt example
User-agent: * Allow: / Sitemap: https://example.com/sitemap-index.xml Sitemap: https://example.com/news-sitemap.xml
Use a full Sitemap URL
To advertise an XML sitemap through robots.txt, add a standalone Sitemap: record with the complete URL, including the protocol and host:
Sitemap: https://example.com/sitemap.xml
Do not use a relative value such as Sitemap: /sitemap.xml. Search engines document the full absolute form, and it is clearer in multi-host or mixed-protocol setups.
The line is not part of a crawler group
Sitemap: is independent of User-agent, Allow, and Disallow. It can appear at the beginning or end of the file. Many sites place sitemap records at the bottom simply because they are easier to maintain there.
If you have several separate sitemap files, add more than one line. If you have a sitemap index, usually one line pointing to the index is enough:
User-agent: *
Allow: /
Sitemap: https://example.com/sitemap-index.xml
Sitemap: https://example.com/news-sitemap.xml
A sitemap does not grant crawl access
The record tells a crawler where a sitemap is located. It does not override a matching robots.txt restriction. If /private/ is disallowed, listing a URL from that directory in the sitemap does not make the page crawlable for that agent.
The reverse is also true: removing a URL from a sitemap does not block it. Crawlers may still discover the URL through internal links, external links, feeds, browser data, or earlier crawl history. Use the appropriate Disallow, page-level indexing control, or server-side restriction for the outcome you actually need.
Choose the correct sitemap address
Open the sitemap URL before publishing the robots.txt line. It should return a successful response and valid sitemap XML rather than an HTML error page, redirect loop, login screen, or expired file. Common CMS locations include /sitemap.xml and /sitemap_index.xml, but the correct value is the address your site really serves.
A sitemap may be hosted separately in some verified cross-site configurations, but each sitemap still needs to describe the intended host correctly. Most ordinary sites should keep the setup simple and reference the sitemap generated for the same site.
Publishing workflow
- Open the sitemap and confirm its final URL and HTTP status.
- Add the absolute
Sitemap:line to the robots.txt file for the exact host. - Publish robots.txt at the host root.
- Open the live file and confirm that the line was not altered by a CMS, CDN, or hosting layer.
- Use the robots.txt checker to verify syntax and any conflicting access rules.
- Optionally submit the sitemap in search-engine webmaster tools for processing reports.
Common mistakes
- Using a relative sitemap path.
- Pointing to an HTML page instead of XML.
- Referencing a staging, HTTP, or obsolete host.
- Assuming the sitemap overrides
Disallow. - Expecting submission to guarantee indexing.
For the record’s exact meaning, see the Sitemap directive glossary. For response failures, review robots.txt HTTP status codes.
FAQ
Where should the Sitemap line go in robots.txt?
It may appear anywhere because it is a standalone record rather than part of a User-agent group. Many sites place it at the end for readability.
Can robots.txt contain multiple Sitemap lines?
Yes. You can list several absolute sitemap URLs. If a sitemap index already lists the individual files, one line pointing to that index is often simpler.
Should the Sitemap value be an absolute URL?
Yes. Use the complete URL including https:// and the host, for example https://example.com/sitemap.xml, rather than a relative path.
Does a Sitemap line override Disallow?
No. Sitemap helps URL discovery, while Allow and Disallow determine crawl permission for the matching crawler group. The access rule still applies.
Does adding a sitemap guarantee indexing?
No. It is a discovery hint. Search engines still evaluate crawl access, HTTP status, canonicalization, content quality, and their own indexing systems.
Sitemap Directive in robots.txt: Meaning and Syntax
robots.txt Checker
robots.txt HTTP Status Codes: 200, 3xx, 4xx, and 5xx
robots.txt Wildcards: * and $ Pattern Matching
Common robots.txt Mistakes and How to Fix Them