Multiple layouts
Answered
Crème D’Argent posted this in #help-forum
Original message was deleted.
Answered by B33fb0n3
take a look at your folder structure and build your route group like this:
113 Replies
Crème D’Argent
@B33fb0n3
Answer
the root layout is not named "root-layout.jsx". It's just a normal layout. It just represents the root layout
Crème D’Argent
i understand that, so i end up with 2 layout.jsx?
yea, one for your (pages) group (for the 3 routes) with the footer and your root layout if you need a root layout
or having multiple root layout is also possible
Crème D’Argent
can i just copy it, and paste it in, the pages?
yea
Crème D’Argent
cool
worked?
Crème D’Argent
but now my root page, broken
why?
Crème D’Argent
do i need to remove something from this new layout file?
you know what you are doing? 🤔
@B33fb0n3 you know what you are doing? 🤔
Crème D’Argent
ehmm, not sure anymore
i see it says "RootLayout"
do you know what the layout.jsx does for your app?
Crème D’Argent
yes
u sure?
Crème D’Argent
it gives the same layout for all pages
so if i add a footer component, the footer will be shown on all pages
you are right. And do you know whats the difference between the root layout and a normal layout?
@B33fb0n3 you are right. And do you know whats the difference between the root layout and a normal layout?
Crème D’Argent
thats where i get lost
root is for the whole app
and normal layout, is only for where i place it?
a normal layout is exactly what you just said.
So in conclusion:
normal layout = just layout like you said.
root layout = layout with html and body tag
The root layout is defined at the top level of the app directory and applies to all routes. This layout is required and must contain html and body tags, allowing you to modify the initial HTML returned from the server.
So in conclusion:
normal layout = just layout like you said.
root layout = layout with html and body tag
A root layout is required, because your page needs the html and body to work. Makes sense, right?
Crème D’Argent
export default function RootLayout({ children }) {
return (
<html lang="en">
<body className={ubuntu.className}>
{children}
<Footer />
</body>
</html>
);
}but what do i need to remove then?
so which layout will be loaded, when you navigate to
/ and which one will be loaded, when you navigate to (pages)/idontremember?Crème D’Argent
/ = root layout
(pages) = normal layout
(pages) = normal layout
can I see your folder structure again, please?
Crème D’Argent
and how the one with the yellow one?
Crème D’Argent
they look the exact same
and thats the issue
this is the Root layout
you found the issue. Congratulations! Now, lets fix this. When you navigating to
(pages)/activities/ for example, which layout(s) will be loaded?it's the layout with the red dot and the one with the yellow dot.
Crème D’Argent
this is the root layout^
and there is the problem. two htmls and two bodys makes no sense..
@Crème D’Argent this is the root layout^
the one with the red dot?
Crème D’Argent
yes this is the red dot
- When you navigating to(pages)/activities/for example, which layout(s) will be loaded?
- it's the layout with the red dot and the one with the yellow dot.
- and there is the problem. two htmls and two bodys makes no sense..
Got it?
Crème D’Argent
no
am lost
my root layout, is correct
the issue comes from my normal layout
the issue is here
export default function RootLayout({ children }) {
return (
<html lang="en">
<body className={ubuntu.className}>
{children}
<Footer />
</body>
</html>
);
}yes! That's what I am trying you to say
take a look at this:
https://nextjs-forum.com/post/1215388872314191882#message-1215394633127956560
You can see the last dot:
https://nextjs-forum.com/post/1215388872314191882#message-1215394633127956560
You can see the last dot:
two htmls and two bodys makes no sense..
The root layout loads the html and body tag and the "normal layout" with the yellow dot tries to load html and body again and that makes no sense
Crème D’Argent
oh okay
i think i got it
you sure?
Crème D’Argent
is this correct?
So you have now 3 options:
1. Remove the html and body stuff from the one with the yellow dot (and add your footer there)
2. Define multiple root layouts [See here](https://nextjs.org/docs/app/building-your-application/routing/route-groups#creating-multiple-root-layouts)
3. I don't know any 3 third option.. lol
1. Remove the html and body stuff from the one with the yellow dot (and add your footer there)
2. Define multiple root layouts [See here](https://nextjs.org/docs/app/building-your-application/routing/route-groups#creating-multiple-root-layouts)
3. I don't know any 3 third option.. lol
Crème D’Argent
so this is correct?
does it work? I don't think so
Please.. I am trying to help you.. 🙂
Crème D’Argent
you could give me the answer
alright: it's wrong.
@Crème D’Argent Click to see attachment
Crème D’Argent
this seems to be right?
but the only thing is the "RootLayout"
which makes me thinking is wrong
yea, and that's the problem. I guess you just modified the layout with the red dot (root layout) so your normal pages at
/ won't have a html and body tag and you pages won't be available.Crème D’Argent
is this correct?>
@B33fb0n3 yea, and that's the problem. I guess you just modified the layout with the red dot (root layout) so your normal pages at / won't have a html and body tag and you pages won't be available.
Crème D’Argent
i havent touched my red dot root layout
ah ok, then nvm
Crème D’Argent
this is the yellow dot normal layout
@Crème D’Argent Click to see attachment
Crème D’Argent
*
does this look correct to you?
it does
Crème D’Argent
it seems to be working
u sure?
Crème D’Argent
oh no
my root page, looks like this
it went from this
show your red dot and your yellow dot
are both loaded when navigating to
/(pages)/somepage/? And is the root layout loaded when navigating to /?Crème D’Argent
i have only changed the from line 24 and down
looks good for me
Crème D’Argent
same to me
this is my page.jsx (root)
@B33fb0n3 footer and no footer
Crème D’Argent
yea, and this is how it should be
but the issue now is that, my / is missing the component
Original message was deleted
Crème D’Argent
see, this is not showing in the /
the footer? Or what component do you mean?
Crème D’Argent
so this is how my / should look like
yea, I understood, that you page.js does not look like how it should look like. Does the footer stuff works?
@B33fb0n3 yea, I understood, that you page.js does not look like how it should look like. Does the footer stuff works?
Crème D’Argent
yes, the footer stuff works now
but my page.jsx is broken now
alright. Your next step is to fix your page. It should look like this: https://nextjs-forum.com/post/1215388872314191882#message-1215399362167971960
Crème D’Argent
yes
and it did that
before i started playing with the layout stuff
yea, that happends when you are programming... sometimes you broke stuff, sometimes you fix stuff, sometimes you catch bugs, sometimes you add new features. And then? Then you fix the next thing and the next and the next and ...
I am not that into your project to help you out with that, sorry
Crème D’Argent
okay, thank you for all your help, you provided. again it was my very first time
Crème D’Argent
i odnt have apps
why not?
Crème D’Argent
i cant close it
Crème D’Argent
you need to hold your finger on one of my messages and then select the "Apps" menu, to mark it as solution
@Crème D’Argent i cant close it
1. Do not delete your original question after it is answered
2. Do not mark something like “I can’t close it†as the solution. Mark the actual solution message instead
2. Do not mark something like “I can’t close it†as the solution. Mark the actual solution message instead