nuxt-modules / sitemap

Powerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.
https://nuxtseo.com/sitemap
333 stars 30 forks source link

Support automatic chunking for multi-sitemap sources #265

Open lxccc812 opened 7 months ago

lxccc812 commented 7 months ago

First of all, thank you for your outstanding contribution.

I have a website with a large number of URLs, about 5,000. I use sitemaps: true to solve the pagination problem. Most of the time, he was able to address my needs. But when I use this method managing-sources, he will not paginate for me, no matter how many URLs there are, and The sitemaps:true functionality is missing.

When I have two sources of data in different categories, I want to be able to distinguish them. For example, I have the following source

sitemap: {
    xsl: false,
    sitemaps: {
        posts: {
            sources: [
                ['/api/food', { headers: { accept: 'application/json' } }],
                ['/api/car', { headers: { accept: 'application/json' } }],
                // and more...
            ],
        },
    },
    excludeAppSources: ['nuxt:pages'],
    cacheMaxAgeSeconds: 60 * 60 * 24, // 1 day
},

I hope to generate the following sitemap

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <script />
    <sitemap>
        <loc>http://localhost:3000/food-sitemap.xml</loc>
        <lastmod>2024-04-12T09:02:56Z</lastmod>
    </sitemap>
    <sitemap>
        <loc>http://localhost:3000/car-sitemap.xml</loc>
        <lastmod>2024-04-12T09:02:56Z</lastmod>
    </sitemap>
</sitemapindex>

Moreover, if there is too much data under http://localhost:3000/food-sitemap.xml, you can use sitemaps:true to paginate again.

harlan-zw commented 6 months ago

Thanks for the feature suggestion, I agree support for paginated named sitemaps is needed.

I don't currently have capacity to attempt this but will revisit when possible.

harlan-zw commented 6 months ago

Related:

censujiang commented 3 months ago

same problem

censujiang commented 3 months ago

For example, enabling sitemapsChunk:true in the code is a flag to turn on this feature

  sitemap: {
    sitemaps: {
      urls:{
        sources: [
          `/api/__sitemap__/urls`,
         sitemapsChunk:true
        ],
      }
    },

I think it is best way to support it. Do you have any idea? @harlan-zw

harlan-zw commented 3 months ago

Yes, I'm open to supporting this it's just a bit complicated and haven't had a chance to tackle it. The configuration will likely be on the sitemaps key (or just re-use the existing config).

jesspinklet commented 2 months ago

I would love to see support for the feature as well. Also, its common as well for large URL websites

Kerimhan05 commented 1 month ago

Hello

Faced the same problem, is there a solution to this problem or is it still relevant?

harlan-zw commented 1 month ago

It's planned but is complicated and low priority for me at the moment.

PRs welcome.

censujiang commented 1 month ago

It's planned but is complicated and low priority for me at the moment.

PRs welcome.

Although this demand is more urgent for large websites, it is very niche for most people. Maybe we need to wait for a destined personšŸ¤£