The definitive guide to XML sitemaps β from protocol basics to dynamic generation, validation, and submission to Google Search Console.
An XML sitemap is a roadmap of your website that helps search engines discover, crawl, and index your pages more efficiently. While search engines can find pages through links, a sitemap accelerates the process β especially for large sites, new websites, or pages that are isolated from the main navigation.
In this guide, we'll cover the sitemap protocol, different types of sitemaps, how to create and validate them, and how to submit them to Google for maximum crawl coverage.
An XML sitemap is an XML file that lists the URLs on your website along with optional metadata about each URL, such as when it was last updated, how often it changes, and its priority relative to other pages on your site.
Think of it as a table of contents for search engines. Instead of relying solely on internal links to discover pages, Googlebot (and other crawlers) can read your sitemap and immediately know about every page you want indexed.
Google recommends having a sitemap if your site meets any of these criteria:
The sitemap protocol is defined at sitemaps.org and uses XML namespace http://www.sitemaps.org/schemas/sitemap/0.9. Here's a standard 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>2026-04-10</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://example.com/about</loc>
<lastmod>2026-03-15</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
</urlset>| Element | Required | Description |
|---|---|---|
<urlset> | β Yes | Root element that wraps all URLs |
<url> | β Yes | Parent element for each URL entry |
<loc> | β Yes | Fully qualified URL (including https://) |
<lastmod> | Optional | Date of last modification (W3C Datetime format) |
<changefreq> | Optional | How often the page changes (Google largely ignores this) |
<priority> | Optional | Priority 0.0β1.0 relative to other pages on your site |
<changefreq> and <priority> are largely ignored in modern crawling. Focus on providing accurate <lastmod> dates and a complete list of URLs.
https://)Lists web pages. This is the most common type and what most websites need.
When you have more than 50,000 URLs, you need multiple sitemaps. A sitemap index file references all individual 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>2026-04-10</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-posts.xml</loc>
<lastmod>2026-04-10</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-products.xml</loc>
<lastmod>2026-04-09</lastmod>
</sitemap>
</sitemapindex>Helps Google discover and index images on your pages:
<url>
<loc>https://example.com/blog/my-article</loc>
<image:image>
<image:loc>https://example.com/images/hero.jpg</image:loc>
<image:title>Article hero image</image:title>
<image:caption>Description of the image</image:caption>
</image:image>
</url>Provides metadata about videos embedded on your pages, including duration, thumbnail, and description. Essential for video SEO.
For news publishers, a news sitemap helps Google discover and index articles quickly. URLs must be no more than two days old.
The fastest way to create a sitemap is using our free XML Sitemap Generator. Simply enter your website URL, and the tool will crawl your site and generate a valid XML sitemap that you can download and upload to your server.
Most CMS platforms have plugins that auto-generate and update sitemaps:
/sitemap.xml/sitemap.xmlFor custom sites or large applications, generate sitemaps dynamically using server-side code. Here's a simple example in Python:
# Python dynamic sitemap generator
import xml.etree.ElementTree as ET
from datetime import datetime
def generate_sitemap(urls):
urlset = ET.Element('urlset')
urlset.set('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9')
for url_data in urls:
url = ET.SubElement(urlset, 'url')
loc = ET.SubElement(url, 'loc')
loc.text = url_data['url']
lastmod = ET.SubElement(url, 'lastmod')
lastmod.text = url_data.get('lastmod', datetime.now().strftime('%Y-%m-%d'))
priority = ET.SubElement(url, 'priority')
priority.text = url_data.get('priority', '0.5')
tree = ET.ElementTree(urlset)
ET.indent(tree, space=' ')
tree.write('sitemap.xml', xml_declaration=True, encoding='UTF-8')
# Usage
urls = [
{'url': 'https://example.com/', 'priority': '1.0'},
{'url': 'https://example.com/about', 'priority': '0.8'},
{'url': 'https://example.com/blog', 'priority': '0.9'},
]
generate_sitemap(urls)For large sites, consider splitting dynamic sitemaps by content type and generating a sitemap index.
Place your sitemap.xml file in your website's root directory so it's accessible at https://yourdomain.com/sitemap.xml.
User-agent: *
Disallow:
Sitemap: https://yourdomain.com/sitemap.xmlAdding your sitemap URL to robots.txt helps crawlers discover it automatically.
Bing uses the same sitemap format. Submit via Bing Webmaster Tools, or use the Bing URL Submission API for automated submission.
<lastmod> when content changes so Google knows when to recrawl.https://www.google.com/ping?sitemap=https://yourdomain.com/sitemap.xml. This notifies Google immediately rather than waiting for the next crawl.
noindex directives, redirected URLs, or error pages..xml.gz) to reduce file size. Google accepts compressed sitemaps.<xhtml:link> elements for alternate language versions.An XML sitemap is one of the most straightforward yet powerful tools in your SEO arsenal. It gives search engines a clear, complete map of your website, ensuring that no important page goes undiscovered. Whether you're launching a new site or managing a sprawling e-commerce platform, a well-maintained sitemap is essential for maximum crawl coverage and indexing speed.
Crawl your site and generate a valid XML sitemap in seconds. Auto-detect pages, images, and URLs with our free sitemap generator.
Try Sitemap Generator β