#Multiple layouts

115 messages · Page 1 of 1 (latest)

vital trenchBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

dusky oracle
#

@hasty pier

hasty pier
#

take a look at your folder structure and build your route group like this:

#

the root layout is not named "root-layout.jsx". It's just a normal layout. It just represents the root layout

dusky oracle
#

i understand that, so i end up with 2 layout.jsx?

hasty pier
#

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

dusky oracle
#

can i just copy it, and paste it in, the pages?

hasty pier
#

yea

dusky oracle
#

cool

hasty pier
#

worked?

dusky oracle
#

but now my root page, broken

hasty pier
#

why?

dusky oracle
#

do i need to remove something from this new layout file?

hasty pier
#

you know what you are doing? 🤔

dusky oracle
#

i see it says "RootLayout"

hasty pier
#

do you know what the layout.jsx does for your app?

dusky oracle
#

yes

hasty pier
#

u sure?

dusky oracle
#

it gives the same layout for all pages

#

so if i add a footer component, the footer will be shown on all pages

hasty pier
#

you are right. And do you know whats the difference between the root layout and a normal layout?

dusky oracle
#

root is for the whole app

#

and normal layout, is only for where i place it?

hasty pier
#

a normal layout is exactly what you just said.

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?

dusky oracle
#

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?

hasty pier
#

so which layout will be loaded, when you navigate to / and which one will be loaded, when you navigate to (pages)/idontremember?

dusky oracle
#

/ = root layout
(pages) = normal layout

hasty pier
#

can I see your folder structure again, please?

dusky oracle
hasty pier
#

how does the layout with the red dot look like?

#

and how the one with the yellow one?

dusky oracle
#

they look the exact same

#

and thats the issue

#

this is the Root layout

hasty pier
#

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.

dusky oracle
#

this is the root layout^

hasty pier
#

and there is the problem. two htmls and two bodys makes no sense..

hasty pier
dusky oracle
#

yes this is the red dot

hasty pier
#
  • 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?

dusky oracle
#

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> ); }

hasty pier
#

yes! That's what I am trying you to say

#

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

dusky oracle
#

oh okay

#

i think i got it

hasty pier
#

you sure?

dusky oracle
#

is this correct?

hasty pier
#

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
  3. I don't know any 3 third option.. lol
dusky oracle
#

so this is correct?

hasty pier
#

does it work? I don't think so

#

Please.. I am trying to help you.. 🙂

dusky oracle
#

you could give me the answer

hasty pier
#

alright: it's wrong.

dusky oracle
#

but the only thing is the "RootLayout"

#

which makes me thinking is wrong

hasty pier
#

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.

dusky oracle
#

is this correct?>

dusky oracle
hasty pier
#

ah ok, then nvm

dusky oracle
#

this is the yellow dot normal layout

dusky oracle
#

does this look correct to you?

hasty pier
#

it does

dusky oracle
#

it seems to be working

hasty pier
#

u sure?

dusky oracle
#

oh no

#

my root page, looks like this

#

it went from this

hasty pier
#

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 /?

dusky oracle
#

i have only changed the from line 24 and down

hasty pier
#

looks good for me

dusky oracle
#

same to me

#

this is my page.jsx (root)

hasty pier
#

footer and no footer

dusky oracle
#

but the issue now is that, my / is missing the component

#

see, this is not showing in the /

hasty pier
#

the footer? Or what component do you mean?

dusky oracle
#

so this is how my / should look like

hasty pier
#

yea, I understood, that you page.js does not look like how it should look like. Does the footer stuff works?

dusky oracle
#

but my page.jsx is broken now

hasty pier
dusky oracle
#

yes

#

and it did that

#

before i started playing with the layout stuff

hasty pier
#

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

dusky oracle
#

okay, thank you for all your help, you provided. again it was my very first time

hasty pier
dusky oracle
#

i odnt have apps

hasty pier
#

why not?

dusky oracle
#

i cant close it

hasty pier
#

It’s the same on mobile

dusky oracle
hasty pier
#

you need to hold your finger on one of my messages and then select the "Apps" menu, to mark it as solution

vital trenchBOT
#
✅ Success!

This question has been marked as answered! If you have any other questions, feel free to create another post

Jump to answer
vital trenchBOT
#
✅ Success!

This question has been marked as answered! If you have any other questions, feel free to create another post

Jump to answer

[Click here](#1215388872314191882 message)

coral vector
# dusky oracle 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