How to Create an XML Sitemap
An XML sitemap is a file that lists every page on your website you want search engines to find, with the date each page was last changed. It does not guarantee indexing, but it helps Google discover new and updated pages faster — especially on new sites with few backlinks. This guide shows you how to build one and submit it to Google Search Console.
What goes inside an XML sitemap
A urlset wrapper, one entry per page
A sitemap is a plain XML file. It opens with a <urlset> wrapper that names the sitemap namespace, and inside it sits one <url> entry per page. Each entry must contain a <loc> element with the full page URL — that is the only required field. Optional fields are <lastmod> (the date the page last changed), <changefreq> (how often it changes) and <priority> (how important it is relative to your other pages). Google largely ignores changefreq and priority today, but it accepts them, and lastmod is genuinely useful.
The 50,000 URL and 50 MB limits
Two hard limits apply. A single sitemap file may hold at most 50,000 URLs and 50 MB uncompressed. Sites bigger than that split their sitemaps into several files and list them all in a sitemap index file. For most small sites, one file is plenty.
Which pages belong in a sitemap
Include what you want indexed
Include every public page you want indexed: your homepage, your main pages, your blog posts, your product or tool pages. Exclude anything you do not want in search results — admin and login pages, carts and checkout, thank-you pages, and any page carrying a noindex tag. Also exclude duplicate URLs and pages that redirect: every URL in the sitemap should return a 200 status and be the canonical version of the page.
Junk URLs waste crawl budget
A sitemap full of junk URLs is worse than a short, clean one. It wastes crawl budget on pages that should never be indexed and can slow down the discovery of the pages that matter. Quality beats quantity here, as it does everywhere in SEO.
Create and submit your sitemap in five steps
- List every page you want indexed. Pull the list from your CMS, from a crawl of your site, or from your own records. Include the full URL with https, one per line, and leave out any page that redirects or carries a noindex tag.
- Generate the XML. Paste the list into the XML Sitemap Generator, add lastmod dates where you know them, and download the finished file. Use the real last-change date for each page — stamping everything with today's date teaches Google to ignore your dates.
- Upload it to your website root. Save the file as sitemap.xml so it loads at https://example.com/sitemap.xml, and add a Sitemap line pointing to it in your robots.txt file. That is where crawlers look first.
- Submit it in Search Console. Open the Sitemaps report in Google Search Console, enter sitemap.xml, and click Submit. The report will show a status — Success, with a count of discovered URLs — usually within a day. If it shows an error, the report names the problem line.
- Keep it fresh. Regenerate the sitemap whenever you add or remove pages, or change a page significantly. A stale sitemap listing dead links is worse than no sitemap at all, because it tells Google your site is not maintained.
Sitemap mistakes to avoid
The most common mistake is including pages that should not be there: noindex pages, redirected URLs, and duplicates. Google notices the mismatch and may start ignoring your sitemap. Listing the same page twice, or with both http and https versions, has the same effect.
The second mistake is never updating it. A sitemap that still lists pages you deleted months ago, or that misses your newest content, is actively unhelpful. The third is forgetting to submit it after a rebuild — uploading the file is only half the job; Search Console needs to know it exists. And a sitemap that returns a 404 because it was uploaded to the wrong folder helps nobody.
Other ways to create a sitemap
WordPress SEO plugins generate a sitemap automatically and update it as you publish, which is the easiest route on that platform. Shopify, Wix and Squarespace also generate sitemaps automatically. For larger sites, a desktop crawler like Screaming Frog can build a sitemap from a full crawl — its free tier covers up to 500 URLs.
The manual generator suits small static sites, where there is no CMS to do the job and a crawl would be overkill. The result is the same either way: a valid XML file at the root of your site.
Related guides
- How to Create a Robots.txt File (Free, in 2 Minutes) — tell search engines which pages to crawl and which to skip.
- How to Add Schema Markup to a Website (JSON-LD, Free) — add JSON-LD schema so Google understands your pages.
- How to Check a Page for Basic SEO (Free Checklist) — a five-minute checklist before you publish a page.
Questions people ask
Does a sitemap guarantee my pages will be indexed?
No. A sitemap is a suggestion, not an order. Google still decides what to index based on quality and crawl budget. It does help discovery, especially for new pages on sites with few backlinks.
Where should my sitemap live?
At the root of your site, at https://example.com/sitemap.xml, and referenced from your robots.txt file. That is where crawlers look first.
How often should I update my sitemap?
Whenever pages are added, removed or significantly changed. On a site that publishes weekly, regenerating weekly is a sensible habit.
What is the 50,000 URL limit?
A single sitemap file may hold at most 50,000 URLs and 50 MB uncompressed. Larger sites split their sitemaps and list them in a sitemap index file.