Markdown pages

Markdown pages

A .md file under src/routes/ is a page. The build compiles it into a component, so from then on it is routed, wrapped in its layouts and rendered like any other — as static HTML, with no JavaScript. This page is one.

Write one

---
title: Pricing
description: What it costs, and what it does not.
---

# Pricing

Plain Markdown, with **GitHub's extensions**: tables, task lists,
~~strikethrough~~ and alerts.

Saved as src/routes/pricing.md, that is /pricing. The routing rules are the same as for components: docs/index.md is /docs, and a layout in the same directory wraps it.

Frontmatter

An optional block at the very top, between --- lines:

KeySets
titleThe page's <title>. Without it, the first # heading is used
descriptionThe page's meta description
tocfalse to drop the contents list; true to keep it for a single heading

Values are one line, bare or in quotes. Any other key fails the build — a misspelt titel is caught rather than silently ignored.

What the page renders

<div class="md-page">
  <article class="md">…the page…</article>
  <nav class="md-toc" aria-label="On this page">…</nav>
</div>

The styling is yours; the build emits structure and class names only. On this site the contents list is the column on the right.

  • Headings get ids the way GitHub makes them — ## Two words is #two-words, and a repeat is numbered -1, -2. Write ## Title {#custom} to choose one. Every heading from ## down links to itself.
  • The contents list holds the ## and ### headings, and appears once a page has two.
  • Code blocks keep their language as data-lang on <pre class="md-code">. There is no syntax highlighting.
  • Alerts — > [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], [!CAUTION] — become <blockquote class="md-callout" data-kind="note"> with a visible label.
  • Tables are wrapped in <div class="md-table">, so a wide one scrolls inside its own box.

Tip

Every character of text reaches the page through the renderer's own escaping. A < in your prose, or </script> in a code sample, is shown as written.

Link to another page by its file:

See [routing](./routing.md#layouts).

The build rewrites that to the page's URL, /docs/routing#layouts — and the same file still reads correctly on GitHub. A link to a .md file that does not exist fails the build, with the file and line. A docs site finds its dead links at build time or not at all.

Links to anything else — https://…, /pricing, #a-heading — are left as written.

What fails the build

Each of these stops albedo build with the file and line, rather than shipping a page with a hole in it:

  • Raw HTML, block or inline. The page is compiled to JSX so that every character goes through the renderer's escaping, and passing HTML through would need a path that skips it. HTML comments are allowed — they are dropped.
  • A dead link to another page, as above.
  • An unknown frontmatter key.
  • A Markdown file where a page cannot be: at a dynamic segment ([slug].md), or named layout.md, error.md or loading.md. Those wrap other routes, so they are components.

Drafts

A file whose name starts with _ is not a page. _pricing.md builds nothing and serves nothing until you rename it.

What Markdown pages do not do

  • No components inside Markdown. For a page that needs one, write the page as a .tsx component.
  • No importing a .md file into a component. A Markdown file is a page, and only a page.
  • No syntax highlighting in code blocks.

Next: how the compiler decides what reaches the browser.