wintercms / wn-sitemap-plugin

Sitemap plugin for Winter CMS
https://wintercms.com/
MIT License
8 stars 5 forks source link

Add support for nested sitemaps #7

Open RomainMazB opened 2 years ago

RomainMazB commented 2 years ago

While discussing the support for this plugin inside the forum plugin, @bennothommo was skeptical about the need to add all the topics urls, due to the true fact that it can make the sitemap go bigger than accepted by the search bots.

The Google's sitemap guidelines says that a sitemap should not include more than 50k links and be smaller than 50Mb. Beyond this limits, the main sitemap file should be a sitemap index which refers nested sitemaps.

As of today, the plugin just cut the sitemap to 50k links: https://github.com/wintercms/wn-sitemap-plugin/blob/ee1d77b325c97dc085b131ad233d0ba60245d280/models/Definition.php#L19 https://github.com/wintercms/wn-sitemap-plugin/blob/ee1d77b325c97dc085b131ad233d0ba60245d280/models/Definition.php#L207-L211

To solve this without adding any limitation, the sitemap plugin should handle nested sitemaps.

Because controlling the sitemap file size any time the search bot renders to optimize it would be difficult, what I suggest here is to let the website's admin decide how the sitemap should be cut.

How I see this feature is:

If no Section model is defined, the plugin would just continue to work as of today.

But if one Section model is defined, the sitemap.xml file would look like this:

<sitemapindex>
  <sitemap>
    <!-- Refers links without Section model attached -->
    <loc>https://example.com/sitemaps/default.xml</loc>
  </sitemap>
  <sitemap>
    <loc>https://example.com/sitemaps/blogposts_1.xml</loc>
  </sitemap>
  <sitemap>
    <loc>https://example.com/sitemaps/blogposts_2.xml</loc>
  </sitemap>
  <sitemap>
    <loc>https://example.com/sitemaps/blogposts_3.xml</loc>
  </sitemap>
</sitemapindex>