{# canonical_base is the OWNING tenant's origin: all 16 Peasy domains serve the same catalogue, so a page rendered by a non-owner points its canonical at the owner instead of competing with it. Falls back to this site for static/self-owned pages. #}
🍋
Menu
How-To Beginner 1 min read 243 words

XML Sitemap Generation and Optimization

XML sitemaps tell search engines which pages exist and when they were updated. Proper sitemap structure ensures efficient crawling, especially for large sites with thousands of pages.

Key Takeaways

  • Search engines discover pages through links.
  • For sites with more than 50,000 URLs (the maximum per sitemap file), use a sitemap index that references multiple sub-sitemaps:
  • Include only canonical, indexable URLs (no noindex, no redirects, no 404s)
  • For database-driven sites, generate sitemaps dynamically rather than maintaining static XML files.
  • Submit your sitemap to Google Search Console and Bing Webmaster Tools.

Why Sitemaps Matter

Search engines discover pages through links. Pages that are deeply nested, recently created, or have few inbound links may not be found without a sitemap. Think of a sitemap as a table of contents for your site.

Sitemap Index Pattern

For sites with more than 50,000 URLs (the maximum per sitemap file), use a sitemap index that references multiple sub-sitemaps:



  
    https://example.com/sitemap-pages.xml
  
  
    https://example.com/sitemap-posts.xml
  

Optional Tags

Tag Purpose Recommendation
Last modification date Include; use ISO 8601 format
How often page changes Ignored by Google; optional
Relative importance (0-1) Ignored by Google; optional

Best Practices

  • Include only canonical, indexable URLs (no noindex, no redirects, no 404s)
  • Keep file size under 50MB uncompressed or 50,000 URLs per file
  • Use gzip compression for large sitemaps
  • Update only when content actually changes (not on every build)
  • Reference the sitemap in robots.txt

Dynamic Sitemaps

For database-driven sites, generate sitemaps dynamically rather than maintaining static XML files. Django, Rails, Next.js, and WordPress all have sitemap generation libraries that query your database and output valid XML.

Monitoring

Submit your sitemap to Google Search Console and Bing Webmaster Tools. Check the coverage report for indexing errors: pages submitted but not indexed, crawl errors, and redirect issues.