Next.js Discord

Discord Forum

Nested dynamic routes /blogs/[slug]/*

Answered
Oak apple gall wasp posted this in #help-forum
Open in Discord
Avatar
Oak apple gall waspOP
How would I represent
/blogs/{slug}
/blogs/{slug}/categories/{slug}
/blogs/{slug}/tags/{slug}
/blogs/{slug}/posts/{slug}

current layout
pages
├── _app.tsx
├── blogs
│   └── [blog_slug]
│       ├── categories
│       │   ├── [category_slug]
│       │   │   └── page.tsx
│       │   └── page.tsx
│       ├── page.tsx
│       ├── posts
│       │   ├── page.tsx
│       │   └── [post_slug]
│       │       └── page.tsx
│       └── tags
│           ├── page.tsx
│           └── [tag_slug]
│               └── page.tsx
└── index.tsx

But
        <h1><Link href={{
            pathname: '/blogs/[slug]',
            query: {slug: data.slug},
        }}>{data.title}</Link></h1>

leads to a 404 page with the following route:
http://localhost:3000/blogs/zweiter-blog
Answered by Oak apple gall wasp
... they need to be called index.tsx, not page.tsx as someone wrote in another question's thread about nested dynamic routes.
View full answer

1 Reply

Avatar
Oak apple gall waspOP
... they need to be called index.tsx, not page.tsx as someone wrote in another question's thread about nested dynamic routes.
Answer