From the course: The Freelance Stack: Real Project with Next.js and Strapi

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Create dynamic routes for all blog articles

Create dynamic routes for all blog articles

Okay, we created the main blog page, which is great. So that one now is exactly how we want it. What we now need though, is that when we click on one of these, it actually brings us to the individual blog page. So in order for us to do that, we will have to do something we haven't done before, which is dynamically create routes depending on our content on Strapi. So for that, we actually can look into the documentation as well, because what we want to do is we want to generate for each slug from our blog articles a new page. And with the app router now, it's a little bit different. Before that, it was getStaticPaths, but now what we will be doing is generate static parameters. So that's exactly the function here. If you look at that, we're going to be doing something very, very similar. will basically say for us here, for the article, we want to pass in the slug from Strapi. So, how are we going to do that? Well, we're going to start by going into Visual Studio Code, and within our…

Contents