You need to use a UI framework Vike extension (vike-react/vike-vue/vike-solid) in order to use the Layout setting. If you don't use vike-react/vike-vue/vike-solid then see Without Vike extension.
What are layouts?
Pages can have different layouts:
for example, if admin panel pages (/admin/product/@id and /admin/user/@id) have a sidebar while marketing pages (/ and /about-us) have a sticky header instead. The admin pages can share the same <Layout> component that includes the sidebar, while the marketing pages can share the <Layout> component that includes the sticky header.
The Layout setting wraps your Page component with another component (the layout component).
<Layout> ⟸ component defined by the setting "Layout" <Page /> ⟸ component defined by the setting "Page"</Layout>
You can apply a layout as default to all pages:
// /pages/+Layout.js// This layout component is the default layoutexport { Layout }// ...
You can then override the default layout on a page-by-page basis:
// pages/product/@id/+Layout.js// This layout component overrides the default layout and// applies to the product page /product/@idexport { Layout }// ...
You can also define a layout for a group of pages:
// /pages/admin/+Layout.js/* This layout applies only to admin pages (/pages/admin/**) such as: URL FILESYSTEM /admin /pages/admin/+Page.js /admin/user/@id /pages/admin/user/@id/+Page.js /admin/product/@id /pages/admin/product/@id/+Page.js*/export { Layout }// ...
See also <Wrapper> which also wraps <Page>, but for different use cases.
If your nested layout isn't associated with a URL (in other words the pricing page and the reviews page share the same URL /product/42), then you can simply use a stateful component instead of the following.
You can implement a nested layout by using a route with multiple parameters:
For smooth nested layout navigation, we recommend using Client Routing. (Using Server Routing leads to full page reloads upon nested layout navigation which usually isn't an acceptable UX.)