<head>, the nav and
the footer. The page supplies only its own content, which lands at the layout’s
<slot />.
Declaring a layout
Layouts live inlayouts/, where they are checked but never emitted as a page.
layouts/base.slurp
{layout} block:
index.slurp
<slot />, and the {head} block replaces
<slot name="head" />.
dist/index.html
<h1>.
The element form has no head slot
There is also an element form,<layout src="@layouts/base">. It fills the
default slot the same way, and that is all it does.
The src must be a quoted string. <layout src={expr}> reads as empty, the
layout is never entered, and the page renders bare.
The head block
A{head} must be a direct child of the {layout} block. The extraction scans
the block’s top-level children only.
{head} inside a component is not extracted either, for the same reason: only
the layout’s own children are scanned.
If a page writes two {head} blocks, the last one wins and the first is
discarded with no diagnostic.
Title and description ownership
Both the layout and the page can write to<head>. In the example theme the
layout owns the title and description, driven by an seo value in the render
context, and the head slot carries additional tags such as a canonical link or
structured data.
layouts/base.slurp
seo gets neither an empty
<title> nor an empty description, and is free to emit its own. Without the
guard a page that emits a title in its head block produces two.
A layout takes no props
So aprops block in a layout is documentation for the reader. To vary a
layout per page, put the value in the render context and read it as a global.
That is what seo does above.
Named slots do not exist
Onlydefault and head are ever filled. Any other name renders as a literal
<slot> element carrying its fallback content.
layouts/base.slurp
index.slurp
dist/index.html
Other slot behaviour
Several default slots duplicate the content
Several default slots duplicate the content
Slot content is cloned per slot. A layout with two
<slot /> elements
renders the page body twice. That is occasionally intended and more often a
typo.A layout with no slot drops the page
A layout with no slot drops the page
{layout "@layouts/noslot"}<p>lost</p>{/layout} renders the layout and
nothing else. The page content is discarded silently.Nesting
A layout can enter another layout, which is how a section shell wraps the site shell.layouts/docs.slurp
@layouts/docs gets both. A layout that enters itself is
stopped by a cycle guard rather than an error.
Imports are per file. A layout that uses a component imports it in its own
frontmatter; it does not inherit the page’s using lines.
layouts/base.slurp
When a layout does not resolve
Like a component, an unresolved layout does not fail the build and is not reported byvalidate --warnings. The page content survives, wrapped in HTML
comments that the minifier then strips, and a literal <slot></slot> is left in
the output.
<slot> in it is a misspelled
layout path.
Layout versus component
Both are.slurp files that other files include, and both are checked without
being emitted. The difference is what they can take.
Use a layout when the file wraps a whole page and needs to reach the head. Use a
component everywhere else, including for regions inside a layout: a component
can be parameterised and a layout cannot.
Next
Components
Props, scope, slots, and imports.
Pages and routing
File-based routing, page data, and output paths.
Sections and blocks
Schema declarations, blocks, and the merge.
Common mistakes
The silent failures, collected in one place.