How to Generate an XML Sitemap for SEO
An XML sitemap is a structured list of every page on your site that you want search engines to crawl and index. It tells crawlers what exists, when it was last modified, and how important each page is relative to others. While Google can discover pages through links, a sitemap ensures nothing is missed β especially on new or large sites.
Sitemap XML Structure
A sitemap is a simple XML file:
<?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-04-15</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
</urlset>Each <url> entry needs only <loc>, the page's full URL. <lastmod> is optional and worth including when it is accurate. <changefreq> and <priority> are in the sitemaps.org protocol, but Google's documentation says plainly that it ignores both, and it uses <lastmod> only when the value is consistently and verifiably accurate β reflecting a significant change to the content, not a footer date or a rebuild.
Priority and Change Frequency: Skip Them
Because Google ignores <priority> and <changefreq>, time spent tuning them (homepage 1.0, posts 0.6β¦) buys nothing in Google Search. Put the effort into <lastmod> instead: set it to the date the page content last changed in a meaningful way and keep it in step with the page's own visible or structured-data date. Bing has published the same advice, describing lastmod as the key signal for when to recrawl. On this site, a build check fails if any sitemap lastmod disagrees with the page's dateModified.
Submitting to Search Engines
Reference your sitemap in robots.txt:
Sitemap: https://example.com/sitemap.xml
Then submit it directly in Google Search Console (Sitemaps section) and Bing Webmaster Tools. After submission, monitor the coverage report β it shows how many URLs were discovered, crawled, and indexed, plus any errors. Resubmit when you add significant new content.
Worked Example: Our Own Sitemap in Search Console
Here is what Google Search Console reported for this site's sitemap on October 13, 2026 (read through the Search Console API):
| Field | Value |
|---|---|
| URLs submitted | 785 |
| Errors / warnings | 0 / 0 |
| Last resubmitted | October 12, 2026 β still "pending" a day later |
| Last downloaded by Google | October 6, 2026 |
| URLs actually indexed (URL Inspection of every page) | 469 of 783 |
Two lessons. Resubmitting asks Google to fetch the file, but on Google's schedule β a day later it had not. And a clean sitemap does not make pages indexed: about 40% of the URLs we listed were crawled or discovered but not indexed, which Google decides from the pages themselves. A sitemap helps discovery; content quality decides indexing.
Dynamic vs Static Sitemaps
Static sites can use a manually generated sitemap β the Sitemap Generator tool creates one from a URL list. Dynamic sites (CMS, e-commerce) should generate sitemaps programmatically on each build or via a route that generates XML on the fly. For sites with more than 50,000 URLs, use a sitemap index file that references multiple sitemap files β each limited to 50,000 URLs or 50MB.
Frequently Asked Questions
What is an XML sitemap?
Do I need a sitemap for SEO?
How do I submit a sitemap to Google?
- [1]Google Search Central: Build and submit a sitemap (Google ignores priority and changefreq; lastmod if accurate) β
- [2]sitemaps.org: Sitemaps XML format protocol (50,000 URLs / 50 MB per file) β
- [3]Bing Webmaster Blog (Feb 2023): The importance of setting the lastmod tag in your sitemap β
- [4]Google Search Console Help: Sitemaps report β