XML Sitemap Guide
The definitive technical reference for Extensible Markup Language sitemaps.
What is an XML Sitemap?
An XML (Extensible Markup Language) sitemap is a strictly structured text file designed entirely for machine consumption. It follows a specific schema defined by sitemaps.org, a protocol agreed upon by Google, Bing, and Yahoo.
The XML Sitemap Anatomy
A valid XML sitemap must begin with an XML declaration, followed by a <urlset> encompassing individual <url> entries.
<?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-08-01</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
</urlset>
Required Tags
<urlset>: The parent tag that encapsulates the file and defines the protocol standard.<url>: The parent tag for each individual URL entry.<loc>: The absolute URL of the page. This must begin with the protocol (e.g., http or https) and end with a trailing slash if your web server requires it. Must be less than 2,048 characters.
Optional Tags
<lastmod>: The date the file was last modified in W3C Datetime format (e.g., YYYY-MM-DD). This is highly valuable if used accurately, as it tells Google when content has changed.<changefreq>: How frequently the page is likely to change. Valid values are: always, hourly, daily, weekly, monthly, yearly, never.<priority>: The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0.
Note on Optional Tags: Google has publicly stated they largely ignore changefreq and priority because webmasters often misuse them (e.g., setting every page to priority 1.0). However, lastmod is heavily utilized, provided it is accurate.
XML Escaping Rules
Because it is an XML file, certain characters in your URLs must be escaped. If you do not escape these, your sitemap will break and be rejected by search engines.
- Ampersand (
&) must become& - Single Quote (
') must become' - Double Quote (
") must become" - Greater Than (
>) must become> - Less Than (
<) must become<
Our Sitemap Generator automatically handles this escaping for you.
Size Limitations & Sitemap Indexes
A single XML sitemap is subject to strict hard limitations imposed by search engines:
- Maximum of 50,000 URLs per file.
- Maximum file size of 50MB (uncompressed).
If your website exceeds these limits, you must generate multiple sitemap files and combine them using a Sitemap Index File. The sitemap index file acts as a directory, pointing to your individual sitemap files.
Dynamic vs. Static Sitemaps
Depending on your website's architecture, you may choose between static or dynamic sitemaps:
- Static Sitemaps: These are manually generated XML files (like those created with our generator tool) that are uploaded to your server. They are ideal for smaller sites or sites where content rarely changes.
- Dynamic Sitemaps: These are automatically generated by your server or CMS (like WordPress or Shopify) whenever a page is added or modified. This ensures your sitemap is always up-to-date without manual intervention, which is essential for large, frequently updated sites.
Common XML Sitemap Errors to Avoid
Submitting an invalid sitemap can cause search engines to ignore it entirely. Watch out for these frequent mistakes:
- Including Non-Canonical URLs: Only include the definitive version of a page. Do not include URLs with tracking parameters or duplicates.
- Including 404 or Redirecting Pages: Every URL in your sitemap should return a 200 OK HTTP status code. Remove dead links and pages that redirect elsewhere.
- Unescaped Special Characters: As mentioned in the escaping rules, failing to escape characters like
&will render the XML invalid. - Incorrect Namespaces: Ensure the
xmlnsattribute in the<urlset>tag exactly matches the sitemaps.org standard.
How to Validate and Submit Your Sitemap
Before submitting your sitemap, it is wise to validate it using an XML validator or a dedicated sitemap validation tool to catch syntax errors.
Once validated, the most effective way to submit your sitemap is through Google Search Console. Navigate to the "Sitemaps" section and enter the URL of your sitemap. Additionally, you should reference your sitemap in your website's robots.txt file to help other search engines discover it.