I can't use and don't understand SSG in nextjs 14
Answered
Cornish Rex posted this in #help-forum
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.
Answered by not-milo.tsx
Given this screenshot you provided in your other thread, the problem is that you're trying to use
You can see that your home page is not dynamic and does not accept parameters like
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
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
2 Replies
Given this screenshot you provided in your other thread, the problem is that you're trying to use
You can see that your home page is not dynamic and does not accept parameters like
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
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
Answer
@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>
Cornish RexOP
Thanks a lot. I understand my mistake. I will read one more time. 😅