Sylla's Blog
Back to blog

Content

6 min read

Dynamic Routes for Posts

Learn how bracket folders turn one page component into many content pages.

By Sylla on

Dynamic routes use square brackets in the folder name. In this project, [slug] receives the post slug from the URL and uses it to find the matching post.

generateStaticParams tells Next.js which dynamic pages can be generated ahead of time. This is a natural fit for static blog content.

When a slug does not exist, the page calls notFound so visitors see the custom 404 screen instead of a broken article.