Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for nested sitemaps #7

Open
RomainMazB opened this issue Jul 17, 2022 · 0 comments
Open

Add support for nested sitemaps #7

RomainMazB opened this issue Jul 17, 2022 · 0 comments

Comments

@RomainMazB
Copy link
Contributor

RomainMazB commented Jul 17, 2022

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants