Technical SEO
XML Sitemaps for SEO: How to Create, Validate, and Submit Them
Updated: · Published: · 4 min read · SEO DOST Editorial
An XML sitemap is a machine-readable file that lists the canonical pages on your website you want search engines to discover and index. Google, Bing, and Yandex use sitemaps to find new and recently updated URLs more efficiently. Submitting a sitemap does not guarantee indexing, but it dramatically improves URL discovery on large, newly launched, frequently updated, or deeply nested websites.
Why XML Sitemaps Matter
Sitemaps surface important pages that crawlers might otherwise miss or take weeks to reach by following internal links alone. They are especially valuable when:
- Your website is brand new and has few external backlinks pointing to it.
- Your site hosts thousands of product pages, listings, or editorial articles.
- Some sections have sparse internal linking or deep category structures.
- You publish or update pages frequently and want crawlers to notice changes quickly.
Even on small, tightly linked sites, maintaining a clean XML sitemap pays off because it unlocks dedicated coverage diagnostics inside Google Search Console.
XML Sitemap Rules and Limits
A single XML sitemap file may contain up to 50,000 URLs and must not exceed 50 MB uncompressed. Larger sites split URLs across multiple child sitemaps and reference them all inside a sitemap index file.
| Rule | Requirement |
|---|---|
| URL limit | Maximum 50,000 URLs per sitemap file |
| File size limit | Maximum 50 MB uncompressed |
| Character encoding | UTF-8 |
| URL format | Fully qualified canonical URLs (including https://) |
lastmod tag |
Update only when page content changes meaningfully |
priority and changefreq |
Ignored by Google |
Which Pages Belong in Your Sitemap?
List only indexable, canonical pages that return an HTTP 200 status code. Including noindex pages, 301/302 redirects, 404 errors, or non-canonical parameter URLs sends conflicting signals to crawlers and muddies Search Console reporting. If you need to pull unwanted pages out of Google's index properly, follow our guide to removing pages from Google.
Using the lastmod Tag Correctly
The <lastmod> element signals when a page's primary content last changed meaningfully. Google uses lastmod when it observes that a site keeps those dates accurate and trustworthy. Automatically bumping every URL's timestamp daily — or updating it for minor template tweaks — degrades signal reliability and causes crawlers to ignore the tag.
How to Generate an XML Sitemap
Most modern platforms generate and maintain XML sitemaps automatically, so hand-coding XML is rarely necessary:
- WordPress: Includes a built-in sitemap at
/wp-sitemap.xmlsince version 5.5, and dedicated WordPress SEO plugins offer finer control over post types and exclusions. - Laravel and custom applications: Generate XML dynamically from your database via a dedicated route, scheduled job, or sitemap package so newly published URLs appear automatically.
- Shopify, Wix, and hosted platforms: Create and update
/sitemap.xmlautomatically whenever products or pages change. - Static site generators: Build clean sitemaps at compile time through standard sitemap plugins.
You can also deploy specialized extensions for images, videos, and Google News articles when relevant. Multilingual websites can include xhtml:link hreflang annotations inside sitemaps as an alternative or complement to HTML head tags.
How to Submit Your Sitemap to Search Engines
Once your XML sitemap is live and returning valid XML, notify search engines through three standard channels:
- Declare it in
robots.txt: Add aSitemap: https://example.com/sitemap.xmlline to your root robots file — you can verify syntax using our robots.txt Generator. - Submit it in Google Search Console: Open the Sitemaps report and enter your sitemap path; see our Google Search Console guide for full setup details.
- Add it to Bing Webmaster Tools and Yandex Webmaster: Both search engines also support the IndexNow protocol for instant URL change notifications.
Google deprecated its legacy sitemap ping endpoint in 2023, so declaring the sitemap in robots.txt and submitting it through Search Console are now the sole official methods for Google.
Auditing and Fixing Sitemap Errors
Keeping a sitemap healthy matters just as much as creating it. Search Console's Sitemaps report flags unreadable XML, HTTP fetch errors, and the exact count of discovered URLs. If there is a wide gap between submitted URLs and indexed pages, inspect the Pages report to see whether crawlers are encountering noindex tags, canonical mismatches, or soft 404s.
You can validate your live sitemap structure, HTTP status codes, and child sitemap indexes immediately with our Sitemap Checker, or review crawlability, canonicals, and technical health together in our free SEO Audit.