Hatch

Site templates and style

On this page

Themes set a site's colors. Templates set everything else: fonts, the text size and type scale, spacing, the column, the header, how posts are listed and the footer. Blogs and portfolios can use them. Docs sites have their own look (see docs/docs-sites.md).

Everything is in .hatch/site.json, typed and checked, so a person, the Publish panel and a coding agent all edit the same few settings instead of raw CSS.

{
  "title": "Ada Lindqvist",
  "kind": "blog",
  "folders": ["Blog"],
  "template": "quiet",
  "style": {
    "tagline": "Design Engineer",
    "width": 644,
    "type": { "h2": { "weight": 550 } }
  }
}

Templates

idLooks like
hatchThe default: a sticky header, headings in a clear scale
quietOne text size, headings by weight only, lots of room, the name with a line under it, warm off-white
indexSmall type, every post on one page grouped by year, dark grey
essayA book serif at 17px, warm paper colors, headings with presence, title and date rows
compactSmall sans type on the left, underlined links, nothing extra

A template is only a starting point. Anything in style wins over it.

Colors: style.colors in the site's own settings win over everything. A template's colors (quiet, index, essay and compact have them) apply only until a theme is picked for that mode in theme.

Your own templates

A look can be saved as a template in the vault, one file per template in .hatch/site-templates/<id>.json:

{
  "name": "Small and plain",
  "help": "14px sans on the left, black on white",
  "base": "quiet",
  "style": { "size": 14, "width": 480, "align": "left" }
}

base is the built-in it starts from (leave it out for hatch) and style takes the same settings as site.json. A site picks it by its id: "template": "small-and-plain". The site's own style still goes on top. The id is the file name: lowercase letters, numbers and dashes, never a built-in's id. In the Look panel, "Save this look as a template" writes the file and picks it. To use a look in another vault, copy the file.

Looks from plugins

A plugin with the site permission can bring looks too (ctx.site.addLook, see plugins.md). They show with your templates and are picked the same way. Your own template with the same id always wins, and a plugin's look with problems isn't offered.

Style

Every setting is a named choice or a number in a range. site.schema.json (written next to site.json) lists them all with their ranges, so editors autocomplete and flag mistakes.

SettingTakesWhat it does
font.body, font.headingssans, system, serif, book, mono, or a name from fontsTypefaces
size13 to 22Body text in px
leading1.2 to 2Body line height
width360 to 960The column in px
scale1 to 1.6Heading sizes: h3 is size × √scale, h2 size × scale, the title size × scale². 1 is flat, headings differ by weight only
headingWeight300 to 800
space0.75 to 2.5Vertical room. 1 is normal, 2 airy. Phones get a third of anything above 1
radius0 to 20Corners of code, cards and pictures
aligncenter, leftWhere the column sits
headerbar, plain, stacked, noneSticky with a line; in the page with no line; the name with the tagline under it; no header at all (/ still opens search)
logoSize16 to 96The logo beside the site name, in px. The picture is site.json’s logo (and logoDark)
logoShapesquare, roundSoft corners, or a circle for a photo of you
taglinetextA line under the site name
nav, search, themeToggleshow, hideThe header's page links, Search button and light/dark switch. Hidden search still opens with /
heroshow, hideThe home page's intro heading. Hidden, it stays for screen readers
postslist, stacked, rows, years, tableHow posts are listed. table has columns for title, tags (when any post has them) and date
postsLabeltextThe heading over the home page's post list
labelsquiet, strong, headingHome page section titles, including the home note's own ## headings
datesshow, hideDates on posts and in lists
readingTimeshow, hide"4 min read" beside a post's date (off by default)
relatedshow, hideUp to three posts that share tags, under each post (off by default). A tag on most posts only counts when nothing rarer is shared
backlinksshow, hide"Linked from": published pages that link to a post, under it (off by default). Links inside %% comments %% don't count
dropCapshow, hideA post's first letter large and dropped into the text, in the heading font (off by default)
pagercards, plain, hideOlder and Newer under a post
footerbar, plain
hoverlist, underline, dim, nonePointing at a post or project in a list: the list’s own look, the title underlines, the other rows fade, or nothing
linksunderline, subtle, plainLinks in text
italicnormal, serifItalic in a serif, set into sans text
codefill, outlineCode as a tinted box, or outlined on the page color
colors.light, colors.dark{ "bg", "text", "accent" } hex colorsTake the place of the site's themes. Hatch works out the rest and keeps text readable
fonts[{ "name", "file", "weight", "style" }]Font files (.woff2, .woff, .ttf, .otf) from the vault. They're copied with the site and .woff2 files are preloaded
type.<role>font, size, weight, tracking, leading, color (text, muted, faint, accent), case, italicOne text role at a time

Text roles: title (a post's title and the home heading), h2, h3, body, homeBody (text on the home page only), brand (the site name), tagline, nav, label (section titles), meta (dates), postTitle, postDesc (in post lists), code.

Pages cross-fading into each other is "transitions": true in site.json (Look panel, Details tab, "Fade between pages"). It's off by default, and readers who ask their device for less motion never see it.

The Look panel's preview

The preview above the Look settings redraws as settings change. A click on a part of the page (the header, the post list, the footer, the text) opens the tab with that part's settings. Links in it open that page of the site in the preview, so post settings (reading time, drop cap, the post slot) can be seen on a post; the back button returns home. Desktop and Phone switch the width: Phone draws the page at 390px, so the site's own phone layout shows. previewPage(files, path, { pick: true }) adds the click-to-part reporting (PreviewPart: header, posts, footer, text).

Header, footer and post slots

Notes can show on every page of a blog or portfolio, or under every post, set in site.json:

"slots": { "header": "Parts/Links.md", "footer": "Parts/Colophon.md", "post": "Parts/Under posts.md" }

The header note sits beside the site name (one line of text, like [twitter](https://…) / [github](https://…)), and the footer note sits above the footer line. Links work as they do in pages, and a link that starts with /, like blog, goes to that address on the site, for pages Hatch makes such as the post list. The notes themselves don't need to be published. The post note sits under every post's text, above "Linked from" and related posts: the place for an author card or a newsletter box. Your own components from .hatch/components work in all three, so an author card can be one component used in one note. In the Look panel they're "Words in the header" (Header tab), "Under each post" (Posts tab) and "Words above the footer" (Details tab).

Series

Posts that belong together name the same series in their properties, and each one shows a small box above its text: "Part 2 of 4 in Grids", with every part linked in date order.

---
date: 2026-02-01
series: Grids
---

A series needs at least two published posts. Related posts never suggest a post's own series parts, since the box already links them.

Two more properties show beside the date when a note has them, for digital gardens: stage: seedling (or budding, evergreen, any short word) as a small label, and updated: 2026-03-02 as "Updated Mar 2, 2026" when it's later than the date. With header: none, every post gets a "← All posts" link above it so readers can still get around.

Posts without a cover get a made picture for link previews (X, Slack, iMessage): the title, the site's name and the date, in the site's colors and heading font, saved beside the post as card.<hash>.png (a new name when the title changes, so previews update). Publishing or downloading from the app makes them, once the site has its address (url, which preview tags need); "cards": false in site.json turns them off. A post with a cover uses its cover.

Home pages

The home note decides the order. Its ## headings become sections, a cards block with look: list is a quiet list of projects, and a posts block puts the post list where you want it (otherwise it goes at the end):

## Today

Working on a course about careful interfaces.

## Projects

```cards
look: list
items:
  - title: Ripple
    text: A tiny notification component.
    link: https://example.com/
```

```posts
title: Writing
```

## More

Find me on GitHub.

Preview, build and measure from the command line

npx tsx packages/publish/src/site-cli.ts preview <vault folder> [--port 4321]
npx tsx packages/publish/src/site-cli.ts build <vault folder> [--out site] [--url https://…] [--cloudflare-analytics]
npx tsx packages/publish/src/site-cli.ts measure <url> [--json]

(Installed, the command is hatch-site.)

  • preview builds the vault's site, serves it at http://localhost:4321/ (this computer only, with clean addresses) and rebuilds on every change in the vault, reusing the pages of notes that didn't change. It prints publish warnings and style problems after each build.
  • build writes the site to a folder (site/ in the vault unless --out says otherwise) for any static host, such as Cloudflare Pages, Netlify or GitHub Pages. It replaces an earlier build there and refuses a folder that holds anything else. It adds a _headers file, which Cloudflare Pages and Netlify read, with the same content security policy Hatch's server sends and a year of caching for files named by their content (staticHeaders() in staticHost.ts). --url sets the public address for this build (canonical links, feed, sitemap) without changing site.json. With a public address, a blog or portfolio also gets link preview pictures for the home page and every post without a cover, drawn with Playwright when it is installed. --cloudflare-analytics lets Cloudflare Web Analytics (free, no cookies) through that policy: turn Web Analytics on in the Pages project and Cloudflare adds its script. Forms, votes, newsletters and private sites need a Hatch server; a static copy has pages, feeds, search and assets.
  • measure opens a live page in a browser (it needs Playwright), reads its colors, text font, size and line height, column width and position, headings and header, and prints a starting style for site.json. Everything is clamped to the settings' ranges, and what has no setting (a font Hatch doesn't have, a column narrower than 360px) is listed under "Not carried over". --json prints the raw numbers too. It only visits the address you give it.

Checking

checkStyle(template, style) from @hatch/publish returns every problem in plain words with where it is (style.width is 2000; it takes 360 to 960.). Publishing lists the same problems as warnings. A site still builds with problems: what can't be used is left out, and nothing in style can add raw CSS.

For agents

  • Over MCP, call site_look first: every setting, its range, the plain words that mean it ("airier" is space, "bolder headings" is headingWeight), the templates, and the site's current style with its problems. check_site_style checks a style before you save it.
  • Without MCP, the same map is styleGuide() from @hatch/publish and the Asks: part of each description in site.schema.json.
  • Change the look by editing template and style in .hatch/site.json. Don't write CSS for anything a setting covers.
  • Start from the template closest to what you're matching, then change the fewest settings.
  • To make a look reusable, write it to .hatch/site-templates/<id>.json (see Your own templates). site_look lists saved templates and their problems.
  • To match a site, run hatch-site measure <url> for a starting style, then compare by eye with hatch-site preview and change the rest (spacing between sections, section titles, post list look).
  • The css setting (a stylesheet in the vault) is still there for the rare thing style can't say.

Where the code is

  • packages/publish/src/siteStyle.ts: templates, the rules, checkStyle, resolveStyle and the schema.
  • packages/publish/src/siteStyleCss.ts: the CSS a resolved style writes.
  • packages/publish/src/siteTemplates.ts: templates saved in the vault: reading, checking and saving them.
  • packages/publish/src/site-cli.ts, staticHost.ts and styleMeasure.ts: the preview, build and measure commands.
  • packages/publish/src/styleFields.ts: every setting's label, group, choices and plain asks. The Look panel (components/SiteLook.tsx) is drawn from it.
  • packages/publish/src/templates.ts: the header (tagline, hidden parts) and post list variants.
  • packages/publish/src/site.ts: applies it to blogs and portfolios, fonts, and the posts block.
  • packages/publish/src/renderCache.ts: createBuildCache(), kept between builds (buildSite(vault, config, { cache })) so a rebuild only parses and draws notes that changed. Previews use it; output is the same without it.
  • Tests: packages/publish/src/siteStyle.test.ts.