Next.js Discord

Discord Forum

I can't use and don't understand SSG in nextjs 14

Answered
Cornish Rex posted this in #help-forum
Open in Discord
Avatar
Cornish RexOP
I have mdx files in my project and I'm fetching them to use them on homepage. I want to make homepage to static generation. I'm getting undefined in my console.log's in generateStaticParams but I can get data in my component. Where is my fault ? Thanks a lot.
Image
Image
Image
Answered by not-milo.tsx
Given this screenshot you provided in your other thread, the problem is that you're trying to use generateStaticParams on a page that doesn't accept any parameter.
You can see that your home page is not dynamic and does not accept parameters like /writings/[slug] does (note the square brackets around slug).

I suggest you read the docs on dynamic routes carefully and understand how they work and how you're supposed to use them. You can find them here: https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes
Image
View full answer

2 Replies

Avatar
Given this screenshot you provided in your other thread, the problem is that you're trying to use generateStaticParams on a page that doesn't accept any parameter.
You can see that your home page is not dynamic and does not accept parameters like /writings/[slug] does (note the square brackets around slug).

I suggest you read the docs on dynamic routes carefully and understand how they work and how you're supposed to use them. You can find them here: https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes
Image
Answer