Next.js Discord

Discord Forum

Server Sitemap using next-sitemap npm package

Unanswered
Irish Setter posted this in #help-forum
Open in Discord
Irish SetterOP
Problem: How to split server-sitemap into multiple sitemaps.

Attempt: I have tried limiting it through the next-sitemap config file like this:

/** @type {import('next-sitemap').IConfig} */
module.exports = {
    siteUrl: process.env.SITE_URL || 'https://www.example.com',
    generateRobotsTxt: true,
    exclude: ['/server-sitemap.xml'],
    sitemapSize: 10000,
    robotsTxtOptions: {
        additionalSitemaps: [
            `${process.env.SITE_URL}/server-sitemap.xml`
        ],
        policies: [
            {
                userAgent: '*',
                allow: '/'
            }
        ]
    }
}


But I don't think this works on the sitemaps on /server-sitemap.xml

Does anyone know how to correctly implement this?

1 Reply

West Highland White Terrier
I was able achieve this by following the docs here https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap#generating-multiple-sitemaps. I'm not using the next-sitemap though.