Next.js Discord

Discord Forum

is it possible to do SSG with page searchParam for pagination?

Answered
Rex posted this in #help-forum
Open in Discord
RexOP
Hi, I have a /blog page on my website that includes a page searchParam for pagination. Since I can calculate the total number of pages, I thought, 'Great! I'll use SSG.' But if I understand correctly, SSG only works with path parameters instead of query parameters, right? If so, is it considered best practice for SEO to replace /blog?page=2 with /blog/2?
Answered by American
Yes, I would use blog/[slug]/page.tsx, and then you can use generateStaticParams to pre-render
View full answer

15 Replies

American
Yes, I would use blog/[slug]/page.tsx, and then you can use generateStaticParams to pre-render
Answer
Actually, seo works with query params, it's a new thing i discovered on my portfolio @Rex
Basically my portfolio uses query params to show designs for specific projects
Notice the value=vibeify
It will open that directly
Try it out
But yes idk how to recreate it, so usually I would recommend path params.. but if you want to use search params google might index those sometimes
Also no you can't ssg search params
RexOP
thanks guys, i'll use /blog/pages/[page]/page.tsx
@Rex thanks guys, i'll use `/blog/pages/[page]/page.tsx`
Sure thing, mark an answer
Original message was deleted
Boop
personally i'd still use search params and use unstable_cache to cache it so it's effectively static
using pathname is okayish? but it's quite inflexible, you can't add another filter that way