How do you add a sitemap to robots.txt?
By TechCompare · Updated · How we check
Use one Sitemap line per file, with a fully qualified URL. The line applies to every crawler, and the sitemap can live on another host.
A Sitemap line in robots.txt tells crawlers where your sitemap lives. Write the full address, like Sitemap: https://www.example.com/sitemap.xml. Put it anywhere in the file. You can add several lines, one per sitemap or index. It belongs to no crawler group, so every crawler that reads the file can use it.
How it works
Google's documentation says the sitemap URL must be fully qualified, so a path like /sitemap.xml doesn't count. The sitemaps.org protocol agrees that the line can go anywhere in the file and that several lines are fine. The tester reads every Sitemap line and reports each file. When the file lists none, it tries /sitemap.xml and says so, since that's a guess and not a statement from the site. It also tests the URLs in the sitemaps against the rules for every crawler in the table, and tells you how many are blocked for each, with examples. A URL that sits in a sitemap and is blocked in robots.txt contradicts itself: the sitemap offers the page and the rules refuse to let the crawler fetch it. The same check shows a sample of sitemap URLs that redirect or fail, because a sitemap should list the address pages actually answer on.
Verdict
List your sitemap index, or each sitemap if you don't have one, with full URLs. Then read the report. Files that don't load, URLs your rules block, and bad lastmod dates are the three things worth fixing first.
More Robots.txt scenarios
Related guides
Frequently asked questions
Does the Sitemap line have to sit under a User-agent line?
Can the sitemap be on a different host than robots.txt?
What if robots.txt lists no sitemap?
Related tools
Open Graph Visualizer
Preview how your website links will look when shared on Google, Twitter, Facebook, and Discord.
Use toolSSL Checker
Check a site's certificate, TLS versions, HTTP/2 and HTTP/3 support, post-quantum key exchange, HSTS and redirects, or compare two sites.
Use toolDNS Lookup
Look up a domain's DNS records on Cloudflare or compare several resolvers at once, and read its SPF, DMARC and DKIM records in plain words.
Use tool