XML Sitemap Best Practices for Large and Small Websites
An XML sitemap is a clean inventory of URLs you want indexed. Its value comes from accuracy, segmentation, and freshness—not from listing every URL the server can produce.
Key takeaways
- Include only canonical, indexable URLs that return successful responses.
- Generate lastmod from meaningful content changes, not every sitemap request.
- Segment large sitemaps by type so coverage problems are easier to diagnose.
- Sitemap publishing needs deployment monitoring: generation success is not the same as a publicly fetchable, current file.
What belongs in an XML sitemap
Include the preferred HTTPS URL for every page that should be indexed. The URL should return 200, allow crawling, permit indexing, and either self-canonicalize or clearly be the selected canonical. Treat inclusion as a quality assertion: this is a real page the site wants search engines to evaluate.
Exclude redirects, errors, noindex pages, duplicate parameters, internal search results, cart and account utilities, staging hosts, and alternate URLs that canonicalize elsewhere. A bloated sitemap sends conflicting signals and makes coverage reports harder to interpret.
Use the correct format and split at practical boundaries
A sitemap can contain up to 50,000 URLs and be up to 50 MB uncompressed, but operationally useful files are often smaller. Use a sitemap index to reference multiple files and group them by content type, locale, product family, or publishing system.
Segmentation creates observability. If blog URLs are indexed well but product sitemaps show a sudden error rate, the responsible template or release is easier to isolate. Keep each file on an allowed host and use absolute, consistently encoded URLs.
- Use UTF-8 and valid XML.
- Return an XML Content-Type and a normal 200 response.
- Reference the sitemap or sitemap index in robots.txt.
Make lastmod trustworthy
The lastmod value should reflect the last significant change to the page: an updated article, new product availability, revised documentation, or changed structured content. Do not set every URL to the time the sitemap was generated. A timestamp that changes daily for untouched pages teaches crawlers to ignore the signal.
Connect lastmod to the same publishing event that updates the page. Use full timestamps when time matters and dates when day-level precision is enough. Keep the value at or before the current time and consistent with visible dateModified markup on editorial pages.
Add extensions only when they provide real discovery value
Image and video sitemap extensions can help when media is a primary search asset and is difficult to discover in the page HTML. News sitemaps have their own freshness rules. For international sites, hreflang can be expressed in sitemaps, but it must remain bidirectional and consistent with page markup.
Do not add complexity simply because the schema permits it. A reliable basic sitemap is more valuable than a fragile sitemap generator with stale media metadata and inconsistent locale relationships.
Submit, monitor, and test the sitemap
Submit the sitemap index in search engine webmaster tools and compare submitted URLs with indexed outcomes. Differences are diagnostic clues, not automatic errors: a URL can be valid yet excluded because it is duplicate, low value, newly discovered, or contradicted by another signal.
Automate checks for invalid XML, non-200 entries, redirecting URLs, unexpected hosts, noindex conflicts, stale lastmod values, and sudden count changes. After a migration, compare the old and new inventories and keep redirects active while crawlers process the transition.
Publish and monitor sitemaps on AWS
Large or frequently updated sites often generate sitemap files in a job and publish them to S3 behind CloudFront. Keep that pipeline deterministic: build from canonical production records, split files before protocol limits, write a sitemap index last, and make the release atomic enough that crawlers never see an index pointing at missing child files. Use stable object names when freshness is controlled by short cache lifetimes, or versioned names when the index can switch references safely.
Set content types correctly and verify that CloudFront does not cache error responses longer than successful sitemap responses. A scheduled Lambda or container task can regenerate the files, but it also needs alarms for failed runs, empty output, unexpected URL-count changes, and public fetch failures. The serverless file-processing architecture is a useful model for separating generation, storage, validation, and notification.
Sitemaps are discovery hints, not a substitute for internal links. Compare the generated URLs with the internal linking strategy guide, canonical tags, and HTTP status results. A URL that exists only in XML remains weakly integrated into the site and may signal that navigation or topic structure needs attention.
- Alert when a sitemap contains zero URLs or changes size beyond an expected range.
- Fetch the public CloudFront URL after publishing, not only the S3 object.
- Keep non-canonical, redirected, blocked, and noindex URLs out of the feed.
- Update lastmod from meaningful content changes rather than every build.
Common questions
Frequently asked questions
Does every website need an XML sitemap?
Small, well-linked sites can be discovered without one, but a sitemap is still a useful, low-cost inventory and diagnostic source. It is especially valuable for large, new, frequently updated, media-heavy, or weakly linked sites.
Should noindex pages appear in a sitemap?
No. A sitemap should contain URLs you want indexed. Including a noindex URL sends contradictory instructions.
How often should an XML sitemap update?
Update it when the canonical indexable URL inventory or meaningful page modification dates change. The cadence should follow publishing, not an arbitrary daily rewrite.
Can a sitemap be hosted on Amazon S3?
Yes. A common pattern publishes generated XML to S3 and serves it through CloudFront, while keeping the sitemap URL under the verified site host and monitoring the public response.
Go deeper
Tools and related resources
Continue the topic
Related guides
Technical SEO Audit Checklist: A Step-by-Step Guide
A useful technical SEO audit follows the path a crawler takes: discover the URL, fetch it, interpret it, select a canonical, and evaluate the page experience.
Internal Linking Strategy: Build Topic Clusters That Work
Internal links help people and crawlers move through a body of knowledge. A good topic cluster is a useful reading path first and an SEO structure second.
llms.txt: What It Is, What It Is Not, and How to Create One
llms.txt is a proposed Markdown index for LLM-friendly website context. It can be a useful map, but it is not access control, a guaranteed crawler directive, or a shortcut around good site architecture.