Skip to main content
100% Free SEO Tools No Sign Up Required
Trusted by 50,000+ SEOs Worldwide
Technical SEO 5 min read 947 words

How to Create and Validate XML Sitemaps

A complete guide to XML sitemap generation, protocol standards, lastmod accuracy, sitemap index structuring, and error-free Google Search Console validation.

TB
Willis Y. Tucker
Technical SEO & Data Research
Published:
•
Updated:

An XML sitemap is a direct, machine-readable declaration to search engine crawlers detailing which URLs on your website are canonical, indexable, and ready for discovery. When structured accurately, it dramatically accelerates the indexing of new content and ensures deep archive pages are not forgotten by web crawlers.

According to official Google Search Central Sitemaps Overview Documentation, an XML sitemap is not a guarantee of indexing, but rather a vital discovery mechanism. Sitemaps are particularly critical for large websites, dynamic e-commerce catalogs, new websites with few external backlinks, and websites with complex media archives.

The standard syntax and protocols for sitemaps are maintained by Sitemaps.org Official Protocol Specifications, supported universally by Google, Microsoft Bing, Yahoo, and DuckDuckGo.

Core Protocol Standards & File Size Limits

Search engines enforce hard limits on individual sitemap files:

Constraint MetricMaximum LimitRemediation Architecture
URL Count per File50,000 URLsSplit into modular sitemaps using a sitemap index file.
Uncompressed File Size50 MBEnable gzip compression (e.g., sitemap.xml.gz).
Character EncodingUTF-8All URL strings and XML entities must be UTF-8 encoded.

Anatomy of a Valid XML Sitemap

A compliant XML sitemap begins with the <urlset> namespace and wraps each entry in a <url> container:

<?xml version=”1.0″ encoding=”UTF-8″?>
<urlset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9″>
<url>
<loc>https://example.com/blog-post/</loc>
<lastmod>2026-10-15T08:30:00+00:00</lastmod>
</url>
</urlset>

Sitemap Index Files: Managing Multi-File Sitemaps

For websites containing thousands of URLs or multiple content types (e.g., posts, products, categories), best practice dictates using a Sitemap Index file (commonly located at /sitemap_index.xml):

<?xml version=”1.0″ encoding=”UTF-8″?>
<sitemapindex xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9″>
<sitemap>
<loc>https://example.com/post-sitemap.xml</loc>
<lastmod>2026-10-16T12:00:00+00:00</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/product-sitemap.xml</loc>
<lastmod>2026-10-15T18:00:00+00:00</lastmod>
</sitemap>
</sitemapindex>

The Critical Importance of the <lastmod> Timestamp

While Google officially ignores <priority> and <changefreq>, it actively reads the <lastmod> tag to calculate recrawl schedules.

However, faking timestamps (such as setting the current date on every URL across your entire site daily) causes search engines to lose trust in your sitemap. Only update <lastmod> when meaningful, substantive content updates have occurred.

What Belongs in Your Sitemap (And What MUST Be Excluded)

A sitemap should only contain clean, canonical, 200 OK indexable URLs:

  • ✓ Include: Canonical blog posts, product pages, core services, category hubs, and landing pages.
  • ✗ Exclude: Pages tagged with noindex, 301 or 302 redirects, 404 error pages, duplicate sorting parameters, thank-you checkout pages, and internal search result pages.
  • ✗ Exclude: Non-canonical URL variants. Always align your sitemap directly with the declarations created by our Canonical Tag Generator and our guide on WordPress canonical troubleshooting.

Before submitting your sitemap to search engines, test it for syntax errors and schema compliance:

Top 6 XML Sitemap Validation Errors & How to Fix Them

Error MessageRoot CauseCorrection Technique
Unescaped XML entityRaw ampersands in URLs (e.g., ?category=seo&page=2).Escape all special characters: &amp;, &apos;, &quot;.
Invalid Date FormatUsing formats like “15/10/2026” or “Oct 15, 2026”.Use ISO 8601 / W3C Datetime format: YYYY-MM-DD.
Sitemap contains redirectsOutdated URLs redirecting via 301/302.Check hops with Redirect Chain Checker; update sitemap to destination URL.
Missing XML NamespaceOmitting xmlns="..." in root <urlset>.Declare standard Sitemaps.org 0.9 schema namespace.
Broken Link in SitemapURLs returning 404 or 410 error codes.Repair or remove URLs following our broken link repair guide.
Blocked by robots.txtA Disallow directive prevents Googlebot from reading the sitemap.Add Allow: /sitemap.xml or remove restrictive disallows.

Submitting & Monitoring Sitemaps in Google Search Console

Once your sitemap is validated:

  1. Log in to Google Search Console and navigate to Indexing → Sitemaps.
  2. Under “Add a new sitemap”, enter your sitemap filename (e.g., sitemap_index.xml) and click Submit.
  3. Search Console will process the file. Check back after 24–48 hours to inspect “Page Indexing” coverage and verify that the ratio of “Indexed pages” to “Submitted pages” remains high.
  4. Cross-reference your indexing trends with query impressions using our GSC Query Performance Analyzer.

Frequently Asked Questions

Where should the sitemap link be placed in robots.txt?
Place the sitemap directive on its own line at the very beginning or end of your robots.txt file, using the absolute URL: Sitemap: https://example.com/sitemap_index.xml.
Do I need an HTML sitemap if I have an XML sitemap?
An XML sitemap is designed specifically for search engines, whereas an HTML sitemap is built for human navigation. Both are valuable; an HTML sitemap provides helpful internal link distribution across deep category archives.

Conclusion & Technical Toolkit

An error-free XML sitemap gives search engines an unobstructed window into your site’s content architecture. Audit your sitemaps after every major deployment to prevent crawling bottlenecks.

Browse our full collection of Technical SEO Audit Tools, master comprehensive technical hygiene with our Technical SEO Audit Guide, and access 185+ free SEO utilities on ToxicBacklink today.

Official Standards & Technical Citations

Primary documentation and technical specifications referenced in this guide.

Free Practical Utilities

Recommended Technical SEO Tools

Browse all 185+ tools →
Frequently Asked Questions

Questions & Answers on This Topic

What is the maximum size of an XML sitemap?
An individual XML sitemap file can contain a maximum of 50,000 URLs and must not exceed 50 megabytes uncompressed. If your website exceeds either limit, you must use a sitemap index file.
Does Google use the priority and changefreq tags in sitemaps?
No. Google officially ignores the and tags in XML sitemaps. However, Google does read and evaluate the timestamp if it reflects genuine content updates.
Should I include 301 redirected pages in my XML sitemap?
Never. Only canonical URLs that return an HTTP 200 OK status should ever be included in an XML sitemap. Including 301 redirects, 404 dead links, or noindex pages wastes crawl budget.
Continue Reading
View all articles →
Free Browser-Based SEO Analysis

Take Control of Your Search Performance

Upload your Google Search Console backlink exports and uncover toxic link patterns in seconds. No subscriptions or account sign-ups required.