An XML sitemap is a file that lists all important URLs on your website to help search engines discover and index your content. It uses the sitemaps.org protocol format and typically lives at domain.com/sitemap.xml. Sitemaps are especially important for large sites, new sites, and sites with complex navigation.
An XML sitemap is a file that lists all important URLs on your website to help search engines discover and index your content. It uses the sitemaps.org protocol format and typically lives at domain.com/sitemap.xml. Sitemaps are especially important for large sites, new sites, and sites with complex navigation.
What is an XML Sitemap?
An XML sitemap is a structured file that provides search engines with a list of pages you want indexed. It helps crawlers find content they might otherwise miss.
Sitemap benefits:
- Helps discover new or updated pages
- Communicates page importance
- Provides metadata (lastmod, priority)
- Improves crawl efficiency
XML Sitemap Structure
Basic Format
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/page/</loc>
<lastmod>2026-01-20</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
</urlset>
Required Elements
| Element | Description |
|---|---|
<urlset> | Container for all URLs |
<url> | Container for each URL entry |
<loc> | The page URL (required) |
Optional Elements
| Element | Description |
|---|---|
<lastmod> | Last modification date |
<changefreq> | Expected change frequency |
<priority> | Relative importance (0.0-1.0) |
Creating XML Sitemaps
CMS Plugins
Most CMS platforms have sitemap plugins.
WordPress:
- Yoast SEO
- Rank Math
- All in One SEO
Other platforms:
- Shopify: Built-in
- Wix: Built-in
- Drupal: XML Sitemap module
Static Site Generators
Astro:
// astro.config.mjs
import sitemap from '@astrojs/sitemap';
export default {
site: 'https://example.com',
integrations: [sitemap()]
};
Next.js:
- next-sitemap package
- Built-in App Router support
Manual Creation
For small static sites.
<?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-01-20</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://example.com/about/</loc>
<lastmod>2026-01-15</lastmod>
<priority>0.8</priority>
</url>
</urlset>
Sitemap Best Practices
What to Include
Include:
- All indexable pages
- Important content pages
- Category and archive pages
- Canonical URLs only
Exclude:
- Noindex pages
- Duplicate content
- Login/admin pages
- Search results pages
- Paginated pages (usually)
URL Consistency
Ensure URLs match your site configuration.
Consistency rules:
- Match canonical URLs exactly
- Include or exclude www consistently
- Use HTTPS if site uses HTTPS
- Include or exclude trailing slashes consistently
Lastmod Usage
Use lastmod accurately.
Good practice:
- Update only when content actually changes
- Use ISO 8601 date format
- Be specific (date or datetime)
Bad practice:
- Updating lastmod on every sitemap generation
- Using current date for all pages
- Omitting for frequently updated content
Priority and Changefreq
Google largely ignores these, but they can help.
Priority guidelines:
- Homepage: 1.0
- Main categories: 0.8
- Regular pages: 0.5-0.7
- Archive pages: 0.3
Changefreq options:
- always, hourly, daily, weekly, monthly, yearly, never
Sitemap Index Files
For large sites with multiple sitemaps.
When to Use
- More than 50,000 URLs
- Sitemap file over 50MB
- Multiple content types to organize
Format
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemap-posts.xml</loc>
<lastmod>2026-01-20</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-products.xml</loc>
<lastmod>2026-01-19</lastmod>
</sitemap>
</sitemapindex>
Organization
Organize sitemaps by content type:
- sitemap-posts.xml
- sitemap-pages.xml
- sitemap-products.xml
- sitemap-categories.xml
Specialized Sitemaps
Image Sitemap
Include images for better image search indexing.
<url>
<loc>https://example.com/page/</loc>
<image:image>
<image:loc>https://example.com/image.jpg</image:loc>
<image:title>Image Title</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:video>
</url>
News Sitemap
For Google News publishers.
<url>
<loc>https://example.com/news-article/</loc>
<news:news>
<news:publication>
<news:name>Publication Name</news:name>
<news:language>en</news:language>
</news:publication>
<news:publication_date>2026-01-20</news:publication_date>
<news:title>Article Title</news:title>
</news:news>
</url>
Submitting Sitemaps
Google Search Console
- Go to Search Console
- Select your property
- Navigate to Sitemaps
- Enter sitemap URL
- Click Submit
robots.txt Reference
Add sitemap location to robots.txt.
Sitemap: https://example.com/sitemap.xml
Bing Webmaster Tools
Similar process to Google Search Console.
Monitoring Sitemaps
Search Console Reports
Check for:
- Submitted vs. indexed URLs
- Errors and warnings
- Coverage issues
Common Issues
| Issue | Cause | Solution |
|---|---|---|
| URLs not indexed | Quality/noindex issues | Check page indexability |
| Sitemap errors | Invalid XML | Validate sitemap |
| URL mismatches | Inconsistent URLs | Use canonical URLs |
| Slow processing | Large sitemap | Split into multiple files |
XML Sitemap Checklist
Creation
- All important pages included
- Noindex pages excluded
- URLs match canonicals
- Valid XML format
- Under 50MB / 50,000 URLs
Optimization
- Accurate lastmod dates
- Organized by content type (large sites)
- Image/video sitemaps if needed
- Referenced in robots.txt
Submission
- Submitted to Google Search Console
- Submitted to Bing Webmaster Tools
- Monitoring for errors
- Regular coverage checks
Conclusion
XML sitemaps help search engines discover and understand your site structure. They’re essential for large sites, new sites, and sites with complex navigation.
Create sitemaps using your CMS or static site generator, include only indexable pages, and keep lastmod dates accurate. Submit to Search Console and monitor for indexing issues.
Combine sitemaps with proper robots.txt configuration and technical SEO best practices for optimal crawling and indexing.