Skip to content

How to have multiple layouts? #7296

Closed Answered by kiliman
gabrielvincent asked this question in Q&A
Discussion options

You must be logged in to vote

There are a couple of ways to share a layout.

As you state above, the Remix way is to create a layout file (prefix with _ if you don't want to include it in the path).

// routes/_mkt.tsx

export default function MktLayout() {
  return (
    <>
      <Header />
      <main>
        <Outlet />
      </main>
      <Footer />
    </>
  );
}

Then, all the routes you want to share that layout with must have that layout as part of the filename. So _mkt.tsx is the layout, and the home page would be _mkt._index.tsx. Remix will render the index route in the <Outlet> of the _mkt layout.

You can also do it the React way by simply importing the shared layout component. Remember, layouts are basically …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@gabrielvincent
Comment options

@nem95
Comment options

@kiliman
Comment options

Answer selected by MichaelDeBoey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants