<what>
title: "Step 1 — Routing"
active_step: 1
</what>
<h1 class="text-3xl font-bold mb-2" style="color: #111827; letter-spacing: -0.02em;">Step 1 — Routing</h1>
<p class="text-gray-500 text-sm mb-8">File structure is your URL structure. No configuration needed.</p>
<section class="mb-8">
<h2 class="text-lg font-semibold mb-3" style="color: #111827;">How it works</h2>
<p class="text-gray-600 mb-4" style="line-height: 1.7;">
wwwhat uses file-based routing. Every <code>.html</code> file inside <code>site/</code> automatically becomes a URL. The directory structure maps directly to paths.
</p>
<div class="card mb-4">
<div class="card-body">
<div class="text-sm font-semibold text-gray-700 mb-3">File → URL mapping</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;">
<div style="background: #f9fafb; border-radius: 0.375rem; padding: 0.75rem;">
<div class="text-xs text-gray-400 mb-2 uppercase font-semibold tracking-wide">File</div>
<div class="font-mono text-sm text-gray-700" style="line-height: 2;">
site/index.html<br>
site/about.html<br>
site/tutorial/1.html<br>
site/blog/[slug].html
</div>
</div>
<div style="background: #f9fafb; border-radius: 0.375rem; padding: 0.75rem;">
<div class="text-xs text-gray-400 mb-2 uppercase font-semibold tracking-wide">URL</div>
<div class="font-mono text-sm text-indigo-600" style="line-height: 2;">
/<br>
/about<br>
/tutorial/1<br>
/blog/hello-world
</div>
</div>
</div>
</div>
</div>
</section>
<section class="mb-8">
<h2 class="text-lg font-semibold mb-3" style="color: #111827;">Dynamic routes</h2>
<p class="text-gray-600 mb-4" style="line-height: 1.7;">
Wrap a filename in square brackets to create a dynamic segment. The value becomes a <code>#params.name#</code> template variable.
</p>
<pre class="bg-gray-50 p-4 rounded text-sm font-mono" style="border: 1px solid #e5e7eb; overflow-x: auto;"><code><span style="color:#6b7280;"><!-- site/blog/[slug].html --></span>
<what>
title: "Blog post"
</what>
<h1>#params.slug#</h1></code></pre>
<p class="text-sm text-gray-500 mt-2">Visit <code>/blog/hello-world</code> and <code>#params.slug#</code> renders as <code>hello-world</code>.</p>
</section>
<section class="mb-8">
<h2 class="text-lg font-semibold mb-3" style="color: #111827;">Live proof</h2>
<p class="text-gray-600 mb-3" style="line-height: 1.7;">
You're on <code>/tutorial/1</code> right now. That URL exists because the file <code>site/tutorial/1.html</code> exists. Click any link below — each one is a file in <code>site/tutorial/</code>.
</p>
<div class="flex gap-2" style="flex-wrap: wrap;">
<a href="/tutorial/1" class="btn btn-outline btn-sm">tutorial/1.html → /tutorial/1</a>
<a href="/tutorial/2" class="btn btn-outline btn-sm">tutorial/2.html → /tutorial/2</a>
<a href="/" class="btn btn-outline btn-sm">index.html → /</a>
</div>
</section>
<section class="mb-8">
<h2 class="text-lg font-semibold mb-3" style="color: #111827;">The <what> block</h2>
<p class="text-gray-600 mb-3" style="line-height: 1.7;">
Every page can have an optional <code><what></code> block at the top. It sets the page title, layout, auth rules, and data fetching. It is stripped from the output — never shown in the browser.
</p>
<pre class="bg-gray-50 p-4 rounded text-sm font-mono" style="border: 1px solid #e5e7eb; overflow-x: auto;"><code><what>
title: "My Page Title"
layout: none
auth: user
fetch.posts = "local:posts"
</what></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>Files in <code>site/</code> become URLs automatically</li>
<li>Directory structure maps to URL paths</li>
<li><code>[name].html</code> creates dynamic routes, accessible via <code>#params.name#</code></li>
<li>The <code><what></code> block controls title, layout, auth, and data — never rendered</li>
</ul>
</div>
</div>