<what>
title: "Step 4 — Layouts"
active_step: 4
</what>
<h1 class="text-3xl font-bold mb-2" style="color: #111827; letter-spacing: -0.02em;">Step 4 — Layouts</h1>
<p class="text-gray-500 text-sm mb-8">Shared page shells with <code>application.what</code> and directory inheritance.</p>
<section class="mb-8">
<h2 class="text-lg font-semibold mb-3" style="color: #111827;">What is a layout?</h2>
<p class="text-gray-600 mb-4" style="line-height: 1.7;">
A layout is a component that wraps all pages in a directory. It provides the shared shell — navigation, sidebar, footer — while the page content is inserted via <code><slot/></code>. You set the layout in an <code>application.what</code> file.
</p>
<pre class="bg-gray-50 p-4 rounded text-sm font-mono" style="border: 1px solid #e5e7eb; overflow-x: auto;"><code><!-- site/tutorial/application.what -->
layout = "components/tutorial-layout.html"</code></pre>
<p class="text-sm text-gray-500 mt-2">
Every page in <code>site/tutorial/</code> now uses this layout. The welcome page at <code>site/index.html</code> does not — it has <code>layout: none</code>.
</p>
</section>
<section class="mb-8">
<h2 class="text-lg font-semibold mb-3" style="color: #111827;">Directory inheritance</h2>
<p class="text-gray-600 mb-4" style="line-height: 1.7;">
Layout config inherits from parent directories to children. You can override or disable it at any level.
</p>
<div class="card mb-4">
<div class="card-body">
<div class="font-mono text-sm" style="line-height: 2.2; color: #374151;">
<div style="color: #6b7280;">site/</div>
<div style="padding-left: 1rem; color: #374151;">index.html <span style="color: #9ca3af; font-family: sans-serif; font-size: 0.75rem;">← no layout (layout: none)</span></div>
<div style="padding-left: 1rem; color: #6b7280;">tutorial/</div>
<div style="padding-left: 2rem; color: #6b7280;">application.what <span style="color: #9ca3af; font-family: sans-serif; font-size: 0.75rem;">← layout = "components/tutorial-layout.html"</span></div>
<div style="padding-left: 2rem; color: #374151;">1.html <span style="color: #9ca3af; font-family: sans-serif; font-size: 0.75rem;">← inherits tutorial-layout.html</span></div>
<div style="padding-left: 1rem; color: #6b7280;">admin/</div>
<div style="padding-left: 2rem; color: #6b7280;">application.what <span style="color: #9ca3af; font-family: sans-serif; font-size: 0.75rem;">← layout = "components/admin.html"</span></div>
<div style="padding-left: 2rem; color: #374151;">dashboard.html <span style="color: #9ca3af; font-family: sans-serif; font-size: 0.75rem;">← inherits admin.html</span></div>
</div>
</div>
</div>
</section>
<section class="mb-8">
<h2 class="text-lg font-semibold mb-3" style="color: #111827;">Disabling the layout</h2>
<p class="text-gray-600 mb-3" style="line-height: 1.7;">
To render a page without any layout — like a landing page or API response — use <code>layout: none</code> in the page's <code><what></code> block.
</p>
<pre class="bg-gray-50 p-4 rounded text-sm font-mono" style="border: 1px solid #e5e7eb; overflow-x: auto;"><code><what>
title: "Landing Page"
layout: none
</what>
<!-- Full HTML output, no wrapper -->
<!DOCTYPE html>
<html>...</html></code></pre>
</section>
<section class="mb-8">
<h2 class="text-lg font-semibold mb-3" style="color: #111827;">Passing data to layouts</h2>
<p class="text-gray-600 mb-3" style="line-height: 1.7;">
Layout components receive props from each page's <code><what></code> block. This tutorial layout uses <code>active_step</code> and <code>title</code> to highlight the correct sidebar item and set the browser tab title.
</p>
<pre class="bg-gray-50 p-4 rounded text-sm font-mono" style="border: 1px solid #e5e7eb; overflow-x: auto;"><code><!-- Page passes props to its layout -->
<what>
active_step: 4
title: "Step 4 — Layouts"
</what>
<!-- Layout declares them -->
<what>
props = "active_step, title"
defaults.active_step = "0"
</what></code></pre>
</section>
<section class="mb-8">
<h2 class="text-lg font-semibold mb-3" style="color: #111827;">The slot</h2>
<p class="text-gray-600 mb-3" style="line-height: 1.7;">
The <code><slot/></code> tag inside a layout is where page content goes. Without it, pages would render with no visible output.
</p>
<pre class="bg-gray-50 p-4 rounded text-sm font-mono" style="border: 1px solid #e5e7eb; overflow-x: auto;"><code><!-- components/tutorial-layout.html -->
<main>
<slot/> <!-- Page content goes here -->
</main></code></pre>
</section>
<div class="card" style="border-color: #bbf7d0; background: #f0fdf4;">
<div class="card-body">
<div class="text-sm font-semibold mb-2" style="color: #14532d;">What you learned</div>
<ul class="text-sm space-y-1" style="color: #166534; padding-left: 1.25rem; list-style: disc;">
<li><code>application.what</code> sets the layout for a directory and all children</li>
<li>Layout config inherits parent-to-child — override at any level</li>
<li><code>layout: none</code> in a page's <code><what></code> block disables the wrapper</li>
<li>Pages pass props to layouts via their <code><what></code> block</li>
<li><code><slot/></code> in a layout marks where page content is inserted</li>
</ul>
</div>
</div>