Next.js Discord

Discord Forum

Static (generated at buildtime) sitemap.xml using getStaticPaths?

Alligator mississippiensis posted this in #help-forum
Open in Discord
Alligator mississippiensisOP

I'm using Next.js for a site that has tons of statically generated content that is fetched from Sanity CMS when the site is built.

I'm using getStaticPaths to create those paths. Is there some way how I can reuse the getStaticPaths in the sitemap generation script? It would make the sitemap generation much easier and less error prone because I could reuse the same logic etc.

Basically I'm looking for a way how to import the component inside of this file:

Thank you 🙂

1 Reply

Alligator mississippiensisOP
I came up with a nasty hack, inside of getStaticPaths function I also create a public/sitemap-blog-posts.xml file, how ugly is this? Is there some nicer way how to do this?