Root Layouts & Nested Layouts
Unanswered
Captain_Ranger posted this in #help-forum
Based on the Next.js Documentation, Root Layouts add the Nested Layouts on their way to the route. Is there a way the Root Layout may be overridden by a nested layout? Or the Root Layout be exempt from being displayed on a route?
Context:
I have a Navbar in my Root Layout. I want this Navbar to be shown in all but one of my routes.
Context:
I have a Navbar in my Root Layout. I want this Navbar to be shown in all but one of my routes.
5 Replies
@Captain_Ranger Based on the Next.js Documentation, Root Layouts add the Nested Layouts on their way to the route. Is there a way the Root Layout may be overridden by a nested layout? Or the Root Layout be exempt from being displayed on a route?
Context:
I have a Navbar in my Root Layout. I want this Navbar to be shown in all but one of my routes.
Is there a way the Root Layout may be overridden by a nested layout?no. the only way is to make the layout containing the navbar not wrap the pages that don't need the navbar, which is doable by using route groups
Siricid woodwasp
Yeah I do this by grouping routes by desired views. My homepage has no navbar so it's just app/page.tsx and app/layout.tsx with no navbar. Then I have app/(dashboard)/layout.tsx with a navbar that applies to all my routes inside of there (app/(dashboard)/account/page.tsx, etc)
Hmm. Interesting solution.
Will certianly give it a go! Thanks @joulev and @Siricid woodwasp!
I have a site with two parts: public facing marketing site and an editor. I don't put the navbar/footer etc in the root layout, I put it in the marketing layout. That's intuitive to me