What Is an XML Sitemap? Format, Limits and Submission
What is an XML sitemap?
An XML sitemap is a file that lists the URLs on a website you want search engines to crawl and index, often with the date each page last changed. It follows the sitemaps.org protocol, which allows up to 50,000 URLs or 50 MB uncompressed per file. A sitemap helps discovery, especially on large or new sites, but it does not make a page rank or force indexing.
What a sitemap does and does not do
Search engines find most pages by following links. A sitemap adds a direct list of URLs you consider important, which helps when links alone are not enough. Google describes a sitemap as a hint: it may crawl the listed URLs sooner, but it still decides whether each page is worth indexing.
- Large sites with thousands of pages, where some may be deep in the structure.
- New sites with few external links pointing to them.
- Sites with rich media or news, which can use sitemap extensions for images, videos and news articles.
- Sites with orphan-prone content, such as archives that internal links rarely reach.
A small site where every page is linked from the navigation may not need a sitemap, but one rarely hurts and most CMSs generate it automatically. It never replaces good internal linking.
The sitemap format
A sitemap is a UTF-8 encoded XML file using the sitemaps.org 0.9 namespace. Each page sits in a <url> element:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.example.com/</loc>
<lastmod>2026-11-01</lastmod>
</url>
<url>
<loc>https://www.example.com/courses/seo/?city=pune&mode=online</loc>
<lastmod>2026-10-18T09:30:00+05:30</lastmod>
</url>
</urlset>| Tag | Required | How Google treats it |
|---|---|---|
| loc | Yes | The full, absolute URL, including https:// and the correct host |
| lastmod | No | Used when it is consistently accurate; ignored on sites that misuse it |
| changefreq | No | Ignored by Google |
| priority | No | Ignored by Google |
Special characters in URLs must be escaped, so & becomes &. Dates use the W3C Datetime format, either a plain date or a date and time with a time zone, such as +05:30 for India.
Size limits and sitemap index files
One sitemap file may contain at most 50,000 URLs and must be no larger than 50 MB uncompressed. You may compress it with gzip to save bandwidth, but the uncompressed limit still applies. Larger sites split URLs across several sitemaps and list them in a sitemap index, which follows the same limits for the number of sitemaps it lists.
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://www.example.com/sitemaps/pages.xml</loc>
<lastmod>2026-11-01</lastmod>
</sitemap>
<sitemap>
<loc>https://www.example.com/sitemaps/products-1.xml.gz</loc>
<lastmod>2026-11-09</lastmod>
</sitemap>
</sitemapindex> Getting lastmod right
Google uses lastmod to decide when to recrawl a page, but only if it trusts the value. Update it when the main content changes meaningfully, such as new information, a corrected price or a rewritten section.
- Do not set every URL to today's date each time the sitemap is generated.
- Do not change it for trivial edits such as a new copyright year in the footer.
- Do take it from a real "content updated" field in your database.
What to include and exclude
A sitemap should list only the URLs you want to appear in search. Every entry should be:
- Indexable, with no
noindextag and not blocked in robots.txt. - The canonical version, not a duplicate that points elsewhere; see how canonical tags work.
- Returning a 200 status, not a redirect or an error.
- On the same host as the sitemap, unless you have verified cross-site submission.
Leave out internal search results, filtered and sorted parameter URLs, login and cart pages, and thin tag archives. Multilingual sites can also list language alternates in the sitemap, as described in the hreflang guide.
Sitemap extensions for images, video and news
Google supports extra namespaces that add detail to a normal sitemap. They are optional and worth adding only when that content type matters for search on your site.
| Extension | Adds | When it helps |
|---|---|---|
| Image | Image URLs used on each page | Images loaded by scripts or otherwise hard for crawlers to find |
| Video | Title, description, thumbnail and video file or player URL | Sites that host their own videos |
| News | Publication name, language and publish date | News publishers; list only articles from the last two days, up to 1,000 per sitemap |
| hreflang (xhtml:link) | Language and regional alternates for each URL | Multilingual or multi-country sites |
A shortened example of an image entry:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>https://www.example.com/projects/kitchen-remodel/</loc>
<image:image>
<image:loc>https://www.example.com/images/kitchen-after.webp</image:loc>
</image:image>
</url>
</urlset> Generating, submitting and monitoring
Most CMSs and SEO plugins create sitemaps automatically. On a custom PHP site you can build one from your database. This short example prints a sitemap from an array:
<?php
$pages = [
['loc' => 'https://www.example.com/', 'lastmod' => '2026-11-01'],
['loc' => 'https://www.example.com/courses/', 'lastmod' => '2026-10-20'],
];
header('Content-Type: application/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>', "\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">', "\n";
foreach ($pages as $page) {
echo ' <url><loc>', htmlspecialchars($page['loc'], ENT_XML1), '</loc>',
'<lastmod>', $page['lastmod'], '</lastmod></url>', "\n";
}
echo '</urlset>', "\n";- Add a
Sitemap:line with the full URL to robots.txt so any crawler can find it. - Submit the sitemap or sitemap index in the Sitemaps report of Google Search Console, and in Bing Webmaster Tools.
- Check the status shows Success and compare discovered URLs with the Page indexing report.
Google retired its sitemap "ping" endpoint in 2023, so use Search Console and an accurate lastmod instead. Sitemap planning for large sites is covered in the online technical SEO course.
Practical exercise: audit a live sitemap
- Open your site's robots.txt and find the Sitemap line, or try /sitemap.xml and /sitemap_index.xml.
- Count the URLs in each file and confirm none exceeds 50,000 entries.
- Crawl the sitemap URLs with a site crawler in list mode and note any that redirect, return 404 or carry
noindex. - Pick five URLs and compare their lastmod with the date the content really changed.
- Write a short fix list: URLs to remove, URLs missing from the sitemap and lastmod logic to correct.
Common mistakes
- Listing redirected, noindexed or non-canonical URLs, which sends mixed signals.
- Setting lastmod to the current date for every URL on every build.
- Spending time tuning priority and changefreq values that Google ignores.
- Using relative URLs or the wrong host, such as http:// on an HTTPS site.
- Expecting a sitemap to get thin or duplicate pages indexed.
Frequently asked questions
Do I need an HTML sitemap as well?
An HTML sitemap is a page for people. It can help navigation on large sites but is not required for search engines if your XML sitemap and internal links are sound.
Where should the sitemap file live?
Usually at the site root, such as /sitemap.xml. A sitemap placed in a folder should normally list only URLs in that folder, unless you submit it through Search Console or reference it from robots.txt.
How long until Google reads a new sitemap?
It is often read within days of submission, but crawling and indexing the URLs it lists can take longer and depends on the site.
Can I have more than one sitemap?
Yes. List them in a sitemap index or submit each one separately in Search Console.