On this page
- What is an XML sitemap and why do search engines need it?
- The official sitemaps.org protocol and XML schema structure
- Essential XML tags: loc and lastmod versus ignored attributes
- Sitemap size limits and constructing sitemap index files
- Specialized sitemaps for images, video, and Google News
- Submitting and monitoring sitemaps in Google Search Console
- Common XML sitemap errors and how to prevent them
- Best practices for dynamic generation and automated sitemap maintenance
- Frequently asked questions
- Does an XML sitemap guarantee that my pages will be indexed?
- How many URLs can a single XML sitemap file contain?
- Does Google still use the changefreq and priority tags?
- Where should I place my XML sitemap on my web server?
- Should I include noindex or redirected URLs in my sitemap?
- Can I compress my XML sitemap using gzip?
- How often does Googlebot check my XML sitemap?
- What is the difference between an XML sitemap and an HTML sitemap?
- Sources
In this guide: Crawling
- What Is a Web Crawler?
- How Googlebot Works
- Search Engine Crawler User Agents: The Full List
- AI Crawlers: GPTBot, ClaudeBot, PerplexityBot and CCBot
- Should You Block AI Crawlers?
- How to Verify Googlebot Is Really Googlebot
- Crawl Budget Explained
- What Is a Crawl Frontier?
- robots.txt: The Complete Guide
- The Robots Exclusion Protocol (RFC 9309)
- robots.txt Mistakes That Kill Traffic
- XML Sitemaps: The Complete Guide
- Image, Video and News Sitemaps
- lastmod: How to Use It Correctly
- IndexNow Explained and How to Set It Up
- The Google Indexing API: What It Is Actually For
- Crawl Errors and How to Fix Them
- Soft 404s Explained
- Orphan Pages: How to Find and Fix Them
- Crawl Traps and Infinite URL Spaces
- Faceted Navigation and Crawl Waste
- HTTP Status Codes Every SEO Should Know
- 301 vs 302 vs 307 vs 308 Redirects
- Redirect Chains and Loops
- How to Read Server Logs for Crawl Analysis
- JavaScript Rendering and the Two-Pass Model
- Dynamic Rendering and Prerendering
An XML sitemap is a structured text document that lists every canonical URL on a website to help search engine crawlers discover, schedule, and fetch pages efficiently. Built using the standard Sitemaps.org XML protocol, it informs crawlers about new and updated content along with precise modification dates. Webmasters submit these documents through search console dashboards to streamline site discovery.
What is an XML sitemap and why do search engines need it?
An XML sitemap is a machine-readable inventory of website URLs formatted according to the universal Sitemaps.org schema specification. It acts as an explicit architectural roadmap for search engines like Google and Bing. By reading this centralized list, automated crawlers can identify newly published pages without having to discover them exclusively through internal hyperlinks.
Traditional search engine crawling relies on hyperlink graph traversal. When a bot visits a homepage, it parses HTML links to discover secondary pages, repeating this process recursively across the domain. While link discovery works well for compact architectures, it leaves significant operational blind spots. Unlinked pages, newly launched product catalogs, and deeply nested archive documents can take weeks or months for crawlers to uncover.
Discovery Pathways:
Traditional Crawl: Homepage ──► Category ──► Subcategory ──► Product (Multi-hop delay)
XML Sitemap: Sitemap File ──► Direct Ingestion of All Canonical URLs (Immediate discovery)XML sitemaps solve this discovery latency. When a publisher adds a URL to a sitemap, search crawlers ingest the address directly into their discovery queue. This mechanism is especially vital for large e-commerce platforms, new domains with few external backlinks, and websites with dynamic content. Understanding how crawlers process these lists is a core element of general web crawler operation.
However, an XML sitemap is a discovery hint rather than an indexing command. Search engines parse the listed URLs, evaluate their quality, and determine crawl priority based on algorithmic signals. Submitting an address inside a sitemap does not guarantee that Google will index or rank the page.
The official sitemaps.org protocol and XML schema structure
The Sitemaps.org protocol is an open standard established jointly in 2006 by Google, Yahoo, and Microsoft to create a unified XML schema for web crawling. Every compliant sitemap file must adhere to strict XML syntactic rules, use UTF-8 character encoding, and declare the official XML namespace URL.
A valid XML sitemap begins with a standard XML declaration followed by the opening <urlset> tag. The <urlset> element encloses individual <url> nodes, each representing a single web document. Within each <url> node, the <loc> tag specifies the full, absolute URL of the page.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/crawling/what-is-a-web-crawler/</loc>
<lastmod>2026-09-01T12:00:00+00:00</lastmod>
</url>
<url>
<loc>https://example.com/crawling/how-googlebot-works/</loc>
<lastmod>2026-09-08T08:30:00+00:00</lastmod>
</url>
</urlset>All URLs listed within the <loc> tag must be fully qualified. Relative paths like /about/ are invalid and will cause parser rejections in search console validation tools. Every URL must also match the exact protocol, domain name, and port of the host serving the sitemap.
Furthermore, special characters within URLs must be properly escaped using XML entity references. An unencoded ampersand in a query parameter will break XML parsing completely. Characters requiring replacement include & as &, ' as ', " as ", > as >, and < as <.
Essential XML tags: loc and lastmod versus ignored attributes
The only two XML sitemap tags that modern search engines actively consume are <loc> and <lastmod>. The remaining attributes defined in the original 2006 Sitemaps.org specification, specifically <changefreq> and <priority>, are completely ignored by Googlebot and Bingbot today.
The <loc> tag is the mandatory core of every entry. It supplies the absolute canonical URL that the crawler should visit. Including non-canonical, redirected, or blocked URLs inside <loc> sends contradictory signals that confuse search engine indexing pipelines.
The <lastmod> tag specifies the date and time when the target page was last substantially updated. When populated with genuine modification timestamps formatted according to the W3C datetime standard (ISO 8601), <lastmod> provides tremendous value. Googlebot uses this timestamp to decide whether it can serve a cached copy or whether it must recrawl the document.
Datetime Formatting in lastmod:
Complete ISO 8601: 2026-09-10T14:20:00+00:00 (Recommended)
Date-only Format: 2026-09-10 (Acceptable)
Invalid Format: 10/09/2026 or Sept 10, 2026 (Parser error)In contrast, <changefreq> and <priority> have fallen into disuse. Historical publishers attempted to manipulate crawling by marking every page as <changefreq>always</changefreq> and <priority>1.0</priority>. Because these values were routinely abused, search engines stopped using them. Google confirmed that Googlebot discards both tags entirely, relying instead on its own machine learning systems to gauge document freshness and crawl cadence.
If your content management system generates <changefreq> or <priority>, leaving them in place does not cause harm. However, engineering teams should not spend development resources maintaining or calculating those values.
Sitemap size limits and constructing sitemap index files
A single XML sitemap file cannot exceed 50,000 URLs or 50 megabytes of uncompressed file size. If a website exceeds either threshold, the webmaster must split the inventory across multiple sitemaps and reference them inside a sitemap index file.
A sitemap index file acts as a parent directory that lists child sitemap URLs. It uses the <sitemapindex> root element and contains individual <sitemap> nodes. Each child node contains a <loc> pointing to a sub-sitemap and an optional <lastmod> indicating when that specific sub-sitemap was regenerated.
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemap-products-1.xml</loc>
<lastmod>2026-09-10T04:00:00+00:00</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-products-2.xml</loc>
<lastmod>2026-09-10T04:00:00+00:00</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-articles.xml</loc>
<lastmod>2026-09-09T18:00:00+00:00</lastmod>
</sitemap>
</sitemapindex>Organizing URLs into logical sub-sitemaps provides major diagnostic benefits. Instead of grouping all pages into arbitrary 50,000-URL buckets, partition them by content type or directory structure:
- Separate product pages into category-specific sitemaps.
- Maintain dedicated sitemaps for editorial articles, documentation, and static pages.
- Group seasonal or promotional landing pages separately.
This segmented structure allows technical teams to isolate indexing bottlenecks in search console reports. If your documentation sitemap achieves a 95 percent indexation rate while your product sitemap stagnates at 40 percent, you know exactly which section of your site architecture requires quality improvements. This optimization directly preserves your domain’s crawl budget capacity.
Both sitemap files and sitemap index files can be compressed using gzip to reduce server bandwidth. A compressed sitemap file typically ends with the .xml.gz extension. When served with the correct Content-Encoding: gzip HTTP header, crawlers decompress and read the file seamlessly.
Specialized sitemaps for images, video, and Google News
The core XML sitemap specification can be extended with specialized XML namespaces to provide search engines with rich metadata for non-text media assets. Google supports custom extensions for images, videos, and news articles.
Image sitemaps allow publishers to identify high-value images embedded inside JavaScript components, galleries, or CSS layouts that crawlers might otherwise miss. Using the http://www.google.com/schemas/sitemap-image/1.1 namespace, an image entry attaches directly to its host page URL:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>https://example.com/products/running-shoe/</loc>
<image:image>
<image:loc>https://example.com/images/running-shoe-side.jpg</image:loc>
<image:title>Lightweight Performance Running Shoe</image:title>
</image:image>
</url>
</urlset>Video sitemaps provide detailed playback and licensing metadata, including video duration, thumbnail URLs, description text, and view counts. This structured metadata helps search engines display video rich snippets and timestamps directly inside search results.
News sitemaps cater to publishers registered in Google News. Unlike standard sitemaps, a Google News sitemap must only contain articles published within the previous 48 hours. Once an article exceeds 48 hours, it should be removed from the news sitemap, though it should remain in your permanent historical sitemap.
For most content websites, separate image sitemaps are unnecessary if images are properly embedded using standard HTML <img> elements with descriptive alt text. However, specialized sitemaps remain essential for portfolio platforms, stock photo agencies, and media broadcasters.
Submitting and monitoring sitemaps in Google Search Console
Publishers submit XML sitemaps to search engines through webmaster platforms and automated discovery channels. The primary manual submission point for Google is the Sitemaps report located inside Google Search Console.
To submit a sitemap, open Search Console, navigate to the Sitemaps tab under Indexing, enter the relative URL path of your sitemap index (for example, sitemap_index.xml), and click Submit. Googlebot will schedule an initial fetch to validate the document syntax.
Submission Pathways:
1. Google Search Console: Direct submission via Indexing > Sitemaps UI
2. Bing Webmaster Tools: Direct submission via Sitemaps dashboard
3. robots.txt Declaration: Sitemap: https://example.com/sitemap.xml
4. Ping Endpoints / IndexNow: Automated API notification upon publishingIn addition to manual console submission, declare your sitemap location directly inside your robots.txt configuration. Add a Sitemap: directive anywhere in the file:
User-agent: *
Allow: /
Sitemap: https://example.com/sitemap_index.xmlThe Sitemap: directive in robots.txt is universally recognized by all compliant web crawlers, including Googlebot, Bingbot, and DuckDuckGo. This entry ensures automated discovery even if you manage hundreds of regional properties without connecting each one manually.
After submission, monitor the Search Console Sitemaps report regularly. The dashboard reports three critical statuses:
- Success: Google processed the sitemap without syntax errors.
- Has errors: The sitemap contains XML syntax mistakes, invalid URLs, or unreachable paths.
- Couldn’t fetch: Googlebot encountered network timeouts, DNS errors, or server failures while trying to download the sitemap.
Reviewing these diagnostic statuses ensures your URL feed remains healthy and functional as detailed in our guide on how Googlebot crawls.
Common XML sitemap errors and how to prevent them
The most damaging sitemap mistake is including dirty URLs that contradict other technical search signals. A sitemap should represent your site’s ideal canonical state. When search engines detect conflicting directives, they lose trust in your sitemap data.
Avoid the following common technical errors:
Common XML Sitemap Errors:
┌───────────────────────────────┬─────────────────────────────────────────────────────────┐
│ Error Type │ Consequence to Search Engine Crawlers │
├───────────────────────────────┼─────────────────────────────────────────────────────────┤
│ Non-200 Status Codes │ Wastes crawler bandwidth on redirects, 404s, and 500s │
│ Blocked by robots.txt │ Crawler cannot fetch URL; raises console warnings │
│ Tagged with noindex │ Contradicts the sitemap request for indexation │
│ Non-Canonical URLs │ Conflicts with rel="canonical" tags on page │
│ Fake or Static lastmod Dates │ Destroys crawler trust in modification signals │
│ Unescaped XML Characters │ Triggers fatal parser syntax errors across entire file │
└───────────────────────────────┴─────────────────────────────────────────────────────────┘Never include URLs that return HTTP 301 redirects, 404 errors, or 500 server faults. Sitemaps should strictly contain live, indexable 200 OK addresses. If you migrate a directory, immediately update your sitemap to point to the new destination addresses rather than leaving old URLs that trigger redirect chains.
Never include URLs that have a noindex robots meta tag. Asking a search engine to index a page in your sitemap while instructing it not to index the page in the HTML header creates an explicit conflict. Crawlers must expend resources fetching the page only to drop it from the index.
Finally, keep your <lastmod> dates honest. Some content management systems update the <lastmod> timestamp of every URL on the site whenever an administrator modifies a global footer or changes a sidebar widget. If Googlebot recrawls thousands of pages and detects no meaningful content changes, it flags your <lastmod> signals as untrustworthy and stops using them to prioritize crawl queues. Following these principles helps you get pages indexed faster.
Best practices for dynamic generation and automated sitemap maintenance
Modern websites should never maintain XML sitemaps manually. Static text files inevitably fall out of synchronization as editors publish, update, and delete content. High-traffic platforms rely on automated, dynamic sitemap pipelines integrated into their content management frameworks.
When designing a dynamic sitemap architecture, generate sitemaps using database event hooks or scheduled background jobs. When an author publishes a new post or updates an article, the application updates the record’s modification timestamp in the database and invalidates the cached sitemap file.
Automated Sitemap Pipeline:
CMS Database Event (Post Updated)
│
▼
Update record timestamp in DB
│
▼
Regenerate XML shard / Invalidate CDN edge cache
│
▼
Emit IndexNow / API ping to search enginesFor high-scale applications containing hundreds of thousands of items, generating XML files synchronously on every HTTP request consumes excessive database resources. Instead, generate sitemap shards asynchronously and store the compressed static XML files on object storage (like Amazon S3 or Google Cloud Storage) or behind a content delivery network (CDN).
Cache sitemap endpoints at your CDN edge with reasonable cache-control headers:
HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8
Content-Encoding: gzip
Cache-Control: public, max-age=3600, stale-while-revalidate=86400This configuration serves fast responses to search engine bots while preventing crawler requests from overwhelming your origin application database. Automated generation paired with robust caching forms the bedrock of reliable search infrastructure explained in Search Engine Basics.
Frequently asked questions
Does an XML sitemap guarantee that my pages will be indexed?
An XML sitemap does not guarantee that your pages will be indexed by search engines. A sitemap acts purely as a discovery mechanism to inform crawlers that a URL exists. Search engines evaluate page quality, relevance, and canonical signals before deciding whether to index a document.
How many URLs can a single XML sitemap file contain?
A single XML sitemap file can contain a maximum of 50,000 URLs and cannot exceed 50 megabytes in uncompressed file size. If your website exceeds either of these limits, you must divide your URLs across multiple sitemap files and combine them using a sitemap index file.
Does Google still use the changefreq and priority tags?
Google does not use the changefreq and priority tags when crawling web pages. Googlebot completely ignores both attributes because historical publishers frequently manipulated their values. Google relies entirely on its own machine learning systems to determine recrawl frequency, although it still reads the lastmod timestamp.
Where should I place my XML sitemap on my web server?
You should place your XML sitemap in the root directory of your web server, such as example.com/sitemap.xml. Placing the sitemap in the root directory ensures that the sitemap has the authority to cover all subdirectories and URL paths across your entire domain.
Should I include noindex or redirected URLs in my sitemap?
You should never include noindex or redirected URLs in your XML sitemap. A sitemap should only contain clean, canonical URLs that return an HTTP 200 OK status code. Including non-canonical, redirected, or blocked addresses creates contradictory signals that waste crawler bandwidth.
Can I compress my XML sitemap using gzip?
You can compress your XML sitemap using gzip to conserve server bandwidth and reduce network transfer latency. Compressed sitemaps typically end with the .xml.gz extension. Search engine crawlers decompress and read these files automatically, provided your server serves the appropriate Content-Encoding header.
How often does Googlebot check my XML sitemap?
Googlebot checks your XML sitemap periodically based on how often your website publishes new content and how reliably your server responds. Highly active news platforms may see their sitemaps checked multiple times per day, while static informational websites may see checks once every few weeks.
What is the difference between an XML sitemap and an HTML sitemap?
An XML sitemap is a machine-readable document built specifically for search engine crawlers to discover and schedule URL fetching. An HTML sitemap is a user-facing navigation page containing clickable links designed to help human visitors navigate broad sections of a website hierarchy.
Sources
Sources
Tier 1 is a search engine's own documentation or a primary standards document. Tier 2 is a reputable secondary publication or a peer-reviewed paper.
- Google Search Central: Sitemaps OverviewGoogle Search CentralTier 1 source: primary documentation or a standards document
- Sitemaps.org: Protocol DocumentationSitemaps XML Protocol GroupTier 1 source: primary documentation or a standards document
- Google Search Central: Build and Submit a SitemapGoogle Search CentralTier 1 source: primary documentation or a standards document
- Microsoft Bing Webmaster Tools: Sitemaps GuidanceMicrosoftTier 1 source: primary documentation or a standards document
Cite this page
Hassan. "XML Sitemaps Explained: Protocol, Setup, and Best Practices." Search Engine Basics, 10 September 2026, https://searchenginebasics.dev/crawling/xml-sitemaps-guide/
@misc{hassan:2026:xml-sitemaps-guide, author = {Hassan}, title = {XML Sitemaps Explained: Protocol, Setup, and Best Practices}, howpublished = {Search Engine Basics}, year = {2026}, url = {https://searchenginebasics.dev/crawling/xml-sitemaps-guide/}}