How to Export an XML Sitemap and Publish It at Your Site Root
Export an XML sitemap from your website or sitemap builder, publish it at /sitemap.xml, and check the served file against your export.

If your goal is a sitemap at https://www.example.com/sitemap.xml, first check what that address serves. Also check /sitemap_index.xml. An existing file may already cover the site, and replacing it without looking could discard URLs you meant to keep. These are common paths to check, not a reason to assume either file exists; Ahrefs suggests checking both before generating a new sitemap.
Export the URLs you intend to publish
For a site with more than a few dozen URLs, Google recommends having the website software generate the sitemap. The software can extract URLs from its database and output them to a file on the web server. Ask whoever maintains the site which URLs that export includes, rather than assuming that every database record belongs in the sitemap.
If your URL set is already in a sitemap builder, export that set instead. In WriteMaps, click Export in the builder, then select Sitemap.xml from the dropdown. That produces a file to publish; downloading it does not, by itself, put it at your site's public URL.
A generator's input matters. A URL-list tool such as KlikWit uses the URLs you supply; it does not discover other pages. A crawler-based export such as the one Ahrefs describes is built from pages its crawler has already crawled. Neither input method should be mistaken for a checked inventory of every URL on your site. Compare the export with the URL set you intended to publish before moving on.
Check the file before uploading it
A minimal sitemap has a UTF-8 XML declaration, the sitemap namespace, and a fully qualified URL in each <loc>. This is a hypothetical one-page export; the date is illustrative, not a value to copy into an unrelated sitemap:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.example.com/guides/sitemap-export</loc>
<lastmod>2025-02-14</lastmod>
</url>
</urlset>
<lastmod> is optional. Include it only when you can keep it accurate: Google says it uses the value when it is consistently and verifiably accurate. Check that each <loc> contains an absolute URL rather than a path such as /guides/sitemap-export, and that XML tag values are entity-escaped where needed. Google requires UTF-8 encoding; a declaration alone is not a substitute for saving the file in that encoding.
Check the export's scale as well. One sitemap is limited to 50,000 URLs or 50 MB uncompressed. If the URL set exceeds either limit, split it into multiple sitemap files; a sitemap index can reference them. Do not truncate a large export merely to make one sitemap.xml fit.
Publish, then inspect the public copy
Name the file sitemap.xml and place it in the site root so the intended public address is https://www.example.com/sitemap.xml. Google recommends root hosting because, unless you submit a sitemap through Search Console, its scope is limited to descendants of its parent directory. If your site already serves a sitemap index at the root, decide how the new file fits alongside it before replacing anything.
Now request the exact public URL, not a local copy or a preview in the export tool. Compare the response with your export: is it the sitemap rather than a missing page or a different file, and does it contain the expected URLs? Checking the public copy matters because exporting and publishing are separate steps. Recheck its encoding, URL format, and per-file limits if the upload or publishing process changed the file.
You can also advertise the published URL in the site's robots.txt file. The Sitemap directive described by Ahrefs would be:
Sitemap: https://www.example.com/sitemap.xml
Make sure that line points to the same URL you just requested. A matching response establishes that the sitemap is served at the intended address and that you can inspect its contents. It does not establish that a search engine has crawled or indexed the listed pages. If the response is missing or the XML is wrong, fix the published file before treating the export as complete.




