Next.js Discord

Discord Forum

How to generate sitemap by SSG or ondemand build

Answered
Nile Crocodile posted this in #help-forum
Open in Discord
Nile CrocodileOP
I have a question on sitemap generation.
Can I make a sitemap SSG?
Or is it possible to regenerate only the sitemap at any given time?
I would be grateful if you could enlighten me.

export async function getStaticProps() {
  const trucksPages = await getSalesCarPages()
  return {
    props: {
      trucksPages,
    },
  }
}

export default async function sitemap({ params }: any)> {

  //I want to refer to the parameters here
  console.log(params)

  const staticPaths: SitemapPaths = []

  const dynamicPaths: SitemapPaths = []

  return [...staticPaths, ...dynamicPaths]
}
Answered by B33fb0n3
I will use this one: https://www.npmjs.com/package/next-sitemap
That looks very good for me. It's postbuild
View full answer

1 Reply

I will use this one: https://www.npmjs.com/package/next-sitemap
That looks very good for me. It's postbuild
Answer