Skip to content

Add support for nested sitemaps #7

@RomainMazB

Description

@RomainMazB

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:

const MAX_URLS = 50000;

protected function makeUrlElement($xml, $pageUrl, $lastModified, $frequency, $priority)
{
if ($this->urlCount >= self::MAX_URLS) {
return false;
}

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:

  • Add a Section model, with a name and a slug
  • Add a 1:1 relation between Definition and Section and the corresponding relation field in the creation a link Definition form
  • Generates multiple files when the Definition links limits goes beyond the 50k limit (ie: blogposts_1.xml, blogposts_2.xml, ...)

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>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions