XML Sitemap Best Practices: The Complete Guide for SEO
Learn XML sitemap best practices for better SEO. How to create, optimize, and submit sitemaps to ensure all your important pages get indexed by search engines.
XML sitemaps help search engines discover and index your pages. A well-optimized sitemap improves crawl efficiency and ensures your important content gets found.
Here’s how to create and optimize your XML sitemap for maximum SEO impact.
What Is an XML Sitemap?
An XML sitemap is a file that lists URLs you want search engines to index. It provides metadata about each URL:
- loc: The URL itself
- lastmod: When the page was last modified
- changefreq: How often the page changes (optional)
- priority: Relative importance (optional)
Location: Typically at https://example.com/sitemap.xml
Basic Sitemap Structure
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2025-01-22</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://example.com/about/</loc>
<lastmod>2024-12-01</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
</urlset>
Sitemap Index Files
For large sites, use a sitemap index to organize multiple sitemaps:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemap-pages.xml</loc>
<lastmod>2025-01-22</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-products.xml</loc>
<lastmod>2025-01-20</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-blog.xml</loc>
<lastmod>2025-01-22</lastmod>
</sitemap>
</sitemapindex>
Sitemap Limits
| Limit | Value |
|---|---|
| URLs per sitemap | 50,000 |
| File size (uncompressed) | 50 MB |
| Sitemaps per index | Unlimited |
If you exceed these limits, split into multiple sitemaps.
Best Practices
1. Only Include Indexable URLs
Your sitemap should only contain pages you want indexed.
Include:
- Pages with 200 status codes
- Pages without noindex
- Canonical URLs (not alternate versions)
- Pages with valuable content
Exclude:
- Noindex pages
- Redirected URLs (3xx)
- Error pages (4xx, 5xx)
- Paginated pages (optional)
- Parameter variations
- Duplicate content URLs
2. Use Accurate lastmod Dates
Only update lastmod when content meaningfully changes.
Good practice:
<!-- Updated when article content changed -->
<lastmod>2025-01-15</lastmod>
Bad practice:
<!-- Updated on every build regardless of content -->
<lastmod>2025-01-22</lastmod>
Google uses lastmod to prioritize crawling. If you abuse it, Google ignores it.
3. Organize Large Sites with Multiple Sitemaps
Split sitemaps by content type for better organization:
/sitemap.xml (index)
├── /sitemap-pages.xml (static pages)
├── /sitemap-blog.xml (blog posts)
├── /sitemap-products.xml (e-commerce products)
├── /sitemap-categories.xml (category pages)
└── /sitemap-locations.xml (local pages)
Benefits:
- Easier to debug
- Clear indexation by section
- Better Search Console reporting
- Faster updates per section
4. Keep Sitemaps Fresh
Generate sitemaps dynamically or update regularly:
- Dynamic: Generated on request (best for active sites)
- Static: Regenerated on content changes
- Scheduled: Rebuilt daily/hourly via cron
5. Use Consistent URLs
Match your canonical URL format:
<!-- If your site uses trailing slashes -->
<loc>https://example.com/about/</loc>
<!-- If your site doesn't use trailing slashes -->
<loc>https://example.com/about</loc>
<!-- Always use HTTPS if that's your canonical -->
<loc>https://example.com/</loc>
6. Include in Robots.txt
Reference your sitemap in robots.txt:
User-agent: *
Allow: /
Sitemap: https://example.com/sitemap.xml
7. Submit to Search Engines
Google Search Console:
- Go to Sitemaps
- Enter sitemap URL
- Click Submit
Bing Webmaster Tools:
- Go to Sitemaps
- Submit sitemap URL
8. Use Gzip Compression (Optional)
For large sitemaps, compress with gzip:
/sitemap-products.xml.gz
Google handles both compressed and uncompressed sitemaps.
Specialized Sitemap Types
Image Sitemap
Include important images for Image Search:
<url>
<loc>https://example.com/page/</loc>
<image:image>
<image:loc>https://example.com/images/photo.jpg</image:loc>
<image:title>Photo description</image:title>
</image:image>
</url>
Video Sitemap
For video content:
<url>
<loc>https://example.com/video-page/</loc>
<video:video>
<video:thumbnail_loc>https://example.com/thumb.jpg</video:thumbnail_loc>
<video:title>Video Title</video:title>
<video:description>Video description</video:description>
<video:content_loc>https://example.com/video.mp4</video:content_loc>
<video:duration>600</video:duration>
</video:video>
</url>
News Sitemap
For Google News publishers:
<url>
<loc>https://example.com/news/article/</loc>
<news:news>
<news:publication>
<news:name>Example News</news:name>
<news:language>en</news:language>
</news:publication>
<news:publication_date>2025-01-22T08:00:00+00:00</news:publication_date>
<news:title>Article Headline</news:title>
</news:news>
</url>
Hreflang Sitemap
For multilingual sites:
<url>
<loc>https://example.com/page/</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/page/"/>
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/page/"/>
<xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/page/"/>
</url>
Common Sitemap Mistakes
Mistake 1: Including Non-Indexable URLs
<!-- WRONG - noindex page in sitemap -->
<url>
<loc>https://example.com/thank-you/</loc>
</url>
This sends mixed signals. If a page is noindex, remove it from the sitemap.
Mistake 2: Wrong URL Format
<!-- WRONG - different from canonical -->
<loc>http://www.example.com/page</loc>
<!-- Site canonical is -->
<loc>https://example.com/page/</loc>
Always match your canonical URL format exactly.
Mistake 3: Outdated Sitemaps
Sitemaps with URLs that redirect or 404 waste crawl budget and look neglected.
Fix: Regularly audit and clean up sitemaps.
Mistake 4: Fake lastmod Dates
<!-- WRONG - updating lastmod on every build -->
<lastmod>2025-01-22T12:00:00Z</lastmod>
If Google notices lastmod is always “now” regardless of content, they’ll ignore it entirely.
Mistake 5: Missing Sitemap Index
For sites with 10,000+ pages using a single sitemap:
Problem: Hard to manage, slow to process.
Solution: Use sitemap index with logical groupings.
Sitemap Audit Checklist
Use this checklist to audit your sitemap:
Structure
- Valid XML format
- Under 50,000 URLs per sitemap
- Under 50MB uncompressed
- Sitemap index used for large sites
- Gzip compression (if large)
URLs
- Only indexable pages included
- Matches canonical URL format
- Uses correct protocol (HTTPS)
- No redirected URLs
- No 404/500 error pages
- No noindex pages
- No parameter variations
Metadata
- lastmod dates accurate
- lastmod only updated on real changes
- Proper date format (W3C)
Submission
- Referenced in robots.txt
- Submitted to Google Search Console
- Submitted to Bing Webmaster Tools
- No submission errors
Maintenance
- Generated automatically or regularly updated
- Monitored for errors
- Cleaned up periodically
Monitoring Sitemap Health
Google Search Console
Check Sitemaps section for:
- Submission status
- URLs discovered
- URLs indexed
- Errors and warnings
Expected vs Actual Indexed
Compare:
- URLs in sitemap
- URLs shown as discovered
- URLs actually indexed
A large gap indicates issues worth investigating.
Related Resources:
Tags:
Share this article:
Ready to improve your SEO?
Get a free SEO audit and see exactly what needs fixing on your site
Start Free Audit