How to have multiple sitemaps?
Unanswered
Sun bear posted this in #help-forum
Sun bearOP
I understand that Nextjs can let you generate dynamic sitemaps on the fly within app -> sitemap.ts file. But this only generate one single sitemap. I have more than 50,000 pages, so I'll need more than one. Apparently, nextjs has this feature available here
https://github.com/vercel/next.js/blob/canary/test/e2e/app-dir/metadata-dynamic-routes/app/gsp/sitemap.ts
But it is undocumented within their documentation. I want to generate different sitemaps for example (jobs, blogs, schools, etc). I tried replicating the example in the link, but doesn't seem to work, the sitemap is not able to be found as shown in this open issue
https://github.com/vercel/next.js/issues/53480
I am on the latest Nextjs
https://github.com/vercel/next.js/blob/canary/test/e2e/app-dir/metadata-dynamic-routes/app/gsp/sitemap.ts
But it is undocumented within their documentation. I want to generate different sitemaps for example (jobs, blogs, schools, etc). I tried replicating the example in the link, but doesn't seem to work, the sitemap is not able to be found as shown in this open issue
https://github.com/vercel/next.js/issues/53480
I am on the latest Nextjs
14 Replies
@Sun bear I understand that Nextjs can let you generate dynamic sitemaps on the fly within app -> sitemap.ts file. But this only generate one single sitemap. I have more than 50,000 pages, so I'll need more than one. Apparently, nextjs has this feature available here
https://github.com/vercel/next.js/blob/canary/test/e2e/app-dir/metadata-dynamic-routes/app/gsp/sitemap.ts
But it is undocumented within their documentation. I want to generate different sitemaps for example (jobs, blogs, schools, etc). I tried replicating the example in the link, but doesn't seem to work, the sitemap is not able to be found as shown in this open issue
https://github.com/vercel/next.js/issues/53480
I am on the latest Nextjs
a few weeks ago, i remember doing this and i had the file at
/app/something/sitemap.ts and visited /something/sitemap.xml@Sun bear I understand that Nextjs can let you generate dynamic sitemaps on the fly within app -> sitemap.ts file. But this only generate one single sitemap. I have more than 50,000 pages, so I'll need more than one. Apparently, nextjs has this feature available here
https://github.com/vercel/next.js/blob/canary/test/e2e/app-dir/metadata-dynamic-routes/app/gsp/sitemap.ts
But it is undocumented within their documentation. I want to generate different sitemaps for example (jobs, blogs, schools, etc). I tried replicating the example in the link, but doesn't seem to work, the sitemap is not able to be found as shown in this open issue
https://github.com/vercel/next.js/issues/53480
I am on the latest Nextjs
Silver cyprinid
I set up a dynamic route and through a hack was able to make sitemaps in buckets of 1000.
You can’t use the built in sitemap for NextJS as that is only equipped for a single sitemap
@Silver cyprinid You can’t use the built in sitemap for NextJS as that is only equipped for a single sitemap
yeah but you can, they just haven't documented it... (idk why)
its been for so many months
@Silver cyprinid I set up a dynamic route and through a hack was able to make sitemaps in buckets of 1000.
yeah using route handlers is the other method
Silver cyprinid
Right - I used route handlers and https://www.npmjs.com/package/next-sitemap
Id prefer to use their built in, but this works for the time being.
@Silver cyprinid I set up a dynamic route and through a hack was able to make sitemaps in buckets of 1000.
Sun bearOP
Hey, I was using next-sitemap before as well, but not the most familiar with sitemap generation in general, since I never found the need for multiple sitemaps until now. Can you elaborate on some of the example of the files you have in place and how you structured it (aka how the root sitemap.xml, the other sitemaps, and the route handlers)
Silver cyprinid
this is the hacky way I did it
Sun bearOP
is that under the pages/api folder?
And I'm assuming your root sitemap.xml is in your public folder, or are you still using the app dir sitemap.ts file? How did you generate the root sitemap dynamically?
And I'm assuming your root sitemap.xml is in your public folder, or are you still using the app dir sitemap.ts file? How did you generate the root sitemap dynamically?
Silver cyprinid
In the app router as an api route.
/app/api/sitemap-news
/app/api/sitemap-news