XML Sitemaps: Build, Submit, and Maintain a Clean Inventory
A practical reference for building, validating, submitting, and maintaining XML sitemaps without sending search engines misleading signals.
Key takeaways
- A sitemap is a discovery signal, not a guarantee that a URL will be indexed.
- Only include canonical, indexable URLs that return a successful response.
- Split large URL sets into focused sitemap files and connect them with a sitemap index.
- Use lastmod only when it reflects a meaningful change to the page.
What an XML sitemap actually does
An XML sitemap is a machine-readable inventory of URLs you want search engines to discover. It is especially useful when a site is new, large, frequently updated, rich in media, or not perfectly connected through internal links.
A sitemap does not replace crawlable navigation. Search engines still evaluate canonical tags, robots directives, response codes, content quality, and internal links before deciding whether to index a URL. Treat the file as a clean feed of eligible pages rather than a complete export of your database.
The minimum valid structure
Each URL belongs in a url element inside a urlset. The loc value must be an absolute URL using the canonical protocol and hostname. Optional lastmod values should use an ISO 8601 date or timestamp.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/guides/xml-sitemaps</loc>
<lastmod>2026-07-18</lastmod>
</url>
</urlset>Escape XML-sensitive characters in URLs. For example, an ampersand in a query string must be written as &.
Which URLs belong in the file
Include the preferred version of every useful public page. Exclude redirects, errors, duplicate parameter URLs, login areas, noindex pages, and URLs canonicalized somewhere else. Every sitemap URL should agree with the signals on the page itself.
- Returns HTTP 200 without requiring a session
- Uses the preferred HTTPS hostname
- Has a self-referencing canonical when it is a unique page
- Is allowed to be crawled and does not contain a noindex directive
- Contains content useful enough to stand on its own
Sitemap files and sitemap indexes
A single sitemap is limited to 50,000 URLs and 50 MB when uncompressed. Sites that exceed either limit should create several sitemap files and list them in a sitemap index. Splitting by content type—products, articles, categories, videos, or locales—also makes coverage problems easier to diagnose.
Place the index at the root and child files alongside it or below it. Without Search Console submission, Google says a sitemap affects descendants of its parent directory. Cross-site hosting requires an explicit cross-submission setup; a different CDN hostname is not automatically authorized just because the file loads.
A maintenance workflow that stays trustworthy
Generate sitemaps from the same canonical URL source used by your application. Remove deleted URLs promptly and update lastmod only after meaningful content changes. Search Console's Sitemaps report describes processing and discovered pages; use the Page indexing report filtered by sitemap and URL Inspection to investigate indexing decisions.
For SitemapKit, discover files first and extract their entries, then compare the returned inventory with the pages you actually want indexed. Extraction is not an indexability audit: check page responses, canonicals, and robots directives separately, and retain any partial-result flags.
Build eligibility into the generator
Start with published content, not every route your router can serve. Join publication state, preferred URL, and indexing policy before serialization. A product draft, an account route, and a canonical article can all return 200; that alone does not qualify them for the search inventory.
Use an XML serializer and measure the resulting UTF-8 bytes, not source-string characters. Gzip reduces transfer size but does not raise the 52,428,800-byte uncompressed limit. Image, video, news, and localized-page extensions have additional rules; a basic loc export does not validate those annotations.
- Publish a page: confirm its preferred URL appears exactly once.
- Unpublish or delete a page: confirm it disappears after regeneration.
- Change a slug: replace the old URL; keep the redirect in the application, not the sitemap.
- Deploy without editing content: confirm unchanged page lastmod values remain stable.
Submit the public file, then separate two outcomes
Fetch the deployed file without a logged-in browser session, validate it, and submit its exact URL under the matching Search Console property. Submission supplies a location; it does not upload a file to Google. Declare the absolute URL in robots.txt too. Google's old sitemap ping endpoint is deprecated, so do not add a ping request to the publishing job.
Successful processing does not mean every page was indexed. If processing fails, investigate the file's transport and syntax. If a page remains absent after processing succeeds, inspect its selected canonical, indexing reason, content, and internal links. Fix the evidence you find rather than repeatedly submitting the same file.
Google ignores priority and changefreq. Neither a higher priority nor a more frequent changefreq forces crawling or improves ranking.
Validate a public sitemap before submitting or auditing it.
Open the free toolFrequently asked questions
Does an XML sitemap improve rankings directly?
No. It helps discovery and diagnostics, but ranking still depends on relevance, quality, usability, internal links, and authority.
Should every page be included?
Only include canonical, indexable pages you would be comfortable seeing in search results. Utility, account, duplicate, redirected, and error URLs should stay out.
How often should a sitemap be regenerated?
Regenerate it when the eligible URL inventory changes. High-frequency sites may update continuously; stable sites can update only after publishing, deleting, or canonicalizing pages.
Primary references
Technical content: SitemapKit Engineering. Maintained by Clément Chaal.
See our technical methodology and editorial policy.