Technical SEO 12 min read

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.

By Rankture Team
XML Sitemap Best Practices: The Complete Guide for SEO

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:

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

LimitValue
URLs per sitemap50,000
File size (uncompressed)50 MB
Sitemaps per indexUnlimited

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:

Exclude:

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:

4. Keep Sitemaps Fresh

Generate sitemaps dynamically or update regularly:

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:

  1. Go to Sitemaps
  2. Enter sitemap URL
  3. Click Submit

Bing Webmaster Tools:

  1. Go to Sitemaps
  2. 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

URLs

Metadata

Submission

Maintenance

Monitoring Sitemap Health

Google Search Console

Check Sitemaps section for:

Expected vs Actual Indexed

Compare:

A large gap indicates issues worth investigating.


Related Resources:

Tags:

xml sitemap sitemaps indexation technical seo search console

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