How to Create an XML Sitemap for Any Website
An XML sitemap is a plain file that lives at the root of your site and lists the URLs you want search engines to discover. It does not force indexing and is not a ranking factor, but for new sites, large sites, and pages buried deep in your navigation it is one of the most reliable discovery signals you control. In this guide: what sitemap.xml contains, which optional tags to fill in and which Google ignores, the one-host rule that makes engines silently discard every URL not on the sitemap’s own host, and how to build a compliant file with the free XML Sitemap Generator and submit it to Google Search Console.
What Is an XML Sitemap?
An XML sitemap is a UTF-8 XML file, usually sitemap.xml in your site root, that follows the protocol defined at sitemaps.org — an open standard from 2006, backed by Google, Yahoo and Microsoft. The format is minimal: every URL sits in a <url> entry with a <loc> child, and everything else is optional.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2026-11-02</lastmod>
</url>
<url>
<loc>https://example.com/pricing/</loc>
<lastmod>2026-10-18</lastmod>
</url>
</urlset>
Search engines read the list, cross it against what they already crawled, and fetch what is new. Sitemaps matter most when link-based discovery is weak: a new site with no backlinks, a large catalogue, a deep archive, or a fresh migration.
lastmod, changefreq and priority: what to fill in and what to skip
Most tutorials show sitemaps stuffed with <lastmod>, <changefreq> and <priority> tags. Two of the three are dead weight at Google, and the third can work against you if you fake it.
<lastmod> — fill it in, but only with real dates. The value uses W3C Datetime format; plain YYYY-MM-DD is fine. Google uses lastmod for crawl scheduling only when the value is “consistently and verifiably accurate,” and the protocol requires the date the page was last modified — not the date the sitemap was generated. If your CMS knows the real modification time, include it; if every rebuild would stamp today’s date on every URL, omit the tag.
<changefreq> — skip it. The protocol defines values like daily and monthly as a hint, not a command, and Google’s documentation says plainly: “Google ignores <priority> and <changefreq> values.”
<priority> — skip it too. Values run from 0.0 to 1.0 and are relative to other URLs on your own site. Google ignores them, and setting everything to 1.0 is the most common way to make the tag meaningless.
The one-host rule
A sitemap may only contain URLs from a single host; its own location decides which URLs qualify. A sitemap at https://www.example.com/sitemap.xml can list https://www.example.com/… URLs, but not https://example.com/… (no www is a different host), not https://blog.example.com/… (subdomains are different hosts), and not another domain at all. Foreign URLs are dropped from consideration: the file is fetched, those URLs go nowhere. When both www and non-www forms of your domain resolve, the sitemap file itself belongs on the host you picked as canonical.
So pick your canonical host — with or without www, HTTPS only — make every <loc> use exactly that form, and keep the sitemap at the site root: the protocol scopes a sitemap to its own path, so /catalog/sitemap.xml can only cover /catalog/ URLs.
How to Create an XML Sitemap Step by Step
Step 1: Collect your canonical URLs
List every URL you want indexed, in its final canonical form — from your CMS export, analytics top pages, or a crawl. If the site is brand-new and small, say twenty pages, the fastest source is your own navigation: walk every menu and list each page by hand. Include pages that return 200 and are indexable; exclude redirects, 404s, noindex pages, and parameter duplicates. Redirects and dead links waste crawl budget; a short, clean list beats a long, dirty one.
Step 2: Verify the risky URLs resolve cleanly
Check at least every URL that predates your last migration or redesign, plus a sample of the rest — old URLs are where dead links hide. The redirect chain checker takes one URL at a time: paste a URL, hit Check redirects, and confirm it returns a 200 on the canonical host without extra hops. Wherever it doesn’t, replace the URL with its final destination.
Step 3: Generate the file with the free XML Sitemap Generator
Open the XML Sitemap Generator and paste your URLs into the Your URLs box, one absolute URL per line (up to 500). Then set the three options. Under Last modified date the select defaults to Use today — switch it to Omit lastmod unless every page really changed today, because the tool stamps one date across the whole list; Custom date only when the pages changed on that date. Under Change frequency and Priority, pick Omit changefreq and Omit priority for the reasons above. Click Generate sitemap.xml and read the checks: the tool skips duplicate lines, rejects malformed URLs, and marks a list mixing URLs from different hosts with an error, not a warning — your signal to fix the list first. When the checks are green, use Copy code or Download sitemap.xml — entity-escaped XML with the correct namespace, ready to upload as-is.
More than 500 URLs? Split the list into chunks, generate and upload sitemap-1.xml, sitemap-2.xml and so on, then point one sitemap index at them and submit the index — not the children — in Search Console:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://yourdomain.com/sitemap-1.xml</loc>
</sitemap>
<sitemap>
<loc>https://yourdomain.com/sitemap-2.xml</loc>
</sitemap>
</sitemapindex>
Step 4: Upload to your site root and declare it in robots.txt
First, check whether you can upload files at all. Hosted platforms maintain the sitemap for you: Shopify, Wix and Squarespace all serve an automatic sitemap at /sitemap.xml. If that is your stack, skip to Step 5 and submit that URL. Otherwise upload the file to https://yourdomain.com/sitemap.xml by SFTP or your host’s file manager, then declare it in robots.txt:
Sitemap: https://yourdomain.com/sitemap.xml
The directive is independent of any User-agent block and can appear more than once. If you are rewriting robots.txt anyway, the free Robots.txt Generator produces the file with the Sitemap line included — and confirm robots.txt is not blocking the pages you listed, because a sitemap cannot override a disallow.
Step 5: Submit to Google Search Console
robots.txt gets you discovered; Search Console gets you diagnostics. If your site is not in GSC yet, add it first — a Domain property (all subdomains, both protocols) or a URL prefix property (one exact prefix) — and verify ownership. Then open Indexing → Sitemaps; the property’s address is pre-filled, so you type just sitemap.xml and click Submit. Within a day the report shows whether Google fetched the file and how many URLs were discovered. Re-submit after major changes. Two notes: the old /ping?sitemap= endpoint was retired in June 2023, so don’t automate pings; and Bing Webmaster Tools can import your site from Search Console (My Sites → Import) — but that imports the site, not your sitemap submissions, so submit the sitemap on BWT’s Sitemaps page separately.
Common XML Sitemap Mistakes
- Listing redirecting or dead URLs. Each wastes crawl budget. Check the risky URLs — at minimum anything older than your last migration — before you generate.
- Mixing hosts. www and non-www in one file is the classic version — the protocol drops foreign URLs.
- Stamping lastmod with the build date. Regenerating the sitemap does not modify your pages. Google uses lastmod only when values are consistently accurate — inflated dates give it reason to disregard yours.
- Including noindex or canonicalized pages. Contradictory signals: “crawl this” and “don’t index this.”
- Letting the sitemap go stale. Shipped a new section three months ago and it is not in the file? That is on the sitemap, not on Google.
- Blocking it with robots.txt. A
Disallow:rule matching/sitemap.xmlhides the file from crawlers that respect the directive.
Frequently Asked Questions
Do I need changefreq and priority in my sitemap?
No. Google’s documentation states that it ignores both <priority> and <changefreq> values. The only optional tag it relies on is <lastmod>, and only when the dates verifiably match when pages changed. Plain <loc> URLs plus honest lastmod dates is the modern best practice.
How many URLs can one sitemap.xml file contain?
Per the sitemaps.org protocol, one sitemap file holds at most 50,000 URLs or 50 MB uncompressed, whichever comes first — you may serve it compressed as sitemap.xml.gz, but the limit still counts the uncompressed size. Beyond that, split the list across files referenced from a sitemap index, submitted in Search Console. The free generator caps one file at 500 URLs; for longer lists, generate sitemap-1.xml, sitemap-2.xml per chunk and wrap them in the Step 3 index.
Where should sitemap.xml go on my server?
In the root directory of your domain, so it is served at https://yourdomain.com/sitemap.xml. Location also scopes content: a sitemap in a subdirectory can only list URLs under that path, and only ever URLs from its own host — when www and non-www both resolve, the file belongs on your canonical host. Root placement on the canonical host avoids all of these problems.
Does my platform build the sitemap for me, and how often should I update it?
Probably. WordPress has generated one at /wp-sitemap.xml since version 5.5, and SEO plugins like Rank Math or Yoast replace it with their own index (typically /sitemap_index.xml). Shopify, Wix and Squarespace maintain /sitemap.xml automatically. If a CMS maintains it there is nothing to regenerate — just verify it in Search Console and exclude noindex post types in the plugin’s settings. If you built the file by hand, regenerate and re-submit whenever you add or retire a significant page.
How long does indexing take after I submit — and is it guaranteed?
The fetch report usually updates within a day. Indexing is separate: pages can take days to weeks to appear, and submission guarantees nothing — a sitemap is a discovery aid, and indexing still depends on crawl budget, content quality, and robots.txt or noindex blocks. Seeing far more discovered URLs than indexed ones is normal; persistent indexing problems usually live on the pages, not in the file.
Search Console says it couldn’t fetch my sitemap. What do I check?
Three causes. “Couldn’t fetch” usually means the file is not served correctly: open /sitemap.xml in a browser, confirm a 200, then check robots.txt — a Disallow: rule matching its path blocks Googlebot. If individual URLs show “URL blocked by robots.txt,” the sitemap lists pages robots.txt disallows; remove them from the list or from robots.txt. And format errors mean broken XML: check that the root element is <urlset> with the sitemaps.org namespace and that ampersands are escaped as &.