Next.js Discord

Discord Forum

Help Building Site with Static / Dynamic Hybrid Structure

House Finch posted this in #help-forum
Open in Discord
House FinchOP
Sorry, this is killing me. I have a custom page in /pages/mySection/index.js which I use to render a custom layout. But I want any eventual subpages to use /pages/[slug]/[subSlug]/index.js. When I build the site I get error > Build error occurred...Error: ENOENT: etc etc because it is trying to build the parent page twice, once via my custom directory and index file, and again via the index file in [slug] 😅

This has to be a common-ish pattern, is there an easy way to handle this in Next.js?

0 Replies