App Router: Is there a way to have index page in a folder like index or _index?
Answered
Australian Freshwater Crocodile posted this in #help-forum
Australian Freshwater CrocodileOP
Hey guys, the question is pretty straightforward: is there a way to have index page in a folder like index or _index? I simply want to have each page inside of a folder so I could colocate components and utils much better. I know that it's possible for any page but not sure about index page?
Answered by jason
Do you want to do something like this?
https://nextjs.org/docs/app/building-your-application/routing/route-groups
https://nextjs.org/docs/app/building-your-application/routing/route-groups
6 Replies
Do you want to do something like this?
https://nextjs.org/docs/app/building-your-application/routing/route-groups
https://nextjs.org/docs/app/building-your-application/routing/route-groups
Answer
Australian Freshwater CrocodileOP
I think nope, I want something like this so index folder would be accessed by
/, not by /indexIf you change your
index folder to be (index) that should workAustralian Freshwater CrocodileOP
Interesting! Though it's a feature that is inteded to be for something else?
From the docs it says
But yeah I've used route grouping in the past to do what you're trying to achieve here.
This allows you to organize your route segments and project files into logical groups without affecting the URL path structure.But yeah I've used route grouping in the past to do what you're trying to achieve here.
Australian Freshwater CrocodileOP
Thank you so much!