Hatch
On this page

A site with kind docs reads like product docs: a header with the logo, search and links, optional tabs, a sidebar built from folders, "On this page", and previous and next at the bottom. The code is packages/publish/src/docs.ts (the page tree) and docsTheme.ts (header, article, styles, script). The browser suite is scripts/e2e-docs.py.

The sidebar comes from folders

  • Each folder under the published one is a group. Deeper folders fold open and shut, and open by themselves when they hold the page you're on. With more than eight groups at one level, those fold too, so a big site's sidebar stays short.
  • A number in front of a folder's name orders it and is left out of its label and its address: 2 Guides shows as Guides at /guides/.
  • A site published from one folder leaves that folder out of its addresses: Acme docs/2 Guides/Writing.md is at /guides/writing/.
  • slug in a note's properties keeps an address. slug: /app/getting-started/installation is the whole address, and slug: start names only the last part. A whole address counts only on a site published from the note's own folder. A home page's slug sends its old address home. Imported pages get the address they had on the original site whenever Hatch's own would differ, so inbound links and search ranking survive the move.
  • Inside a folder, pages go by order in their properties, then by title. A folder's own note (index.md, README.md, or one named like the folder) comes first.
  • With tabs on, each top-level folder is a tab in the header with its own sidebar. Pages outside them go under Overview.
  • A folder's own note with the folder's name is listed as Overview under the folder's label.
  • Folders named in variants (like Radix UI and Base UI) hold versions of the same pages. Where they sit side by side, the sidebar lists the pages once, from the version being read (the first one elsewhere). Each page gets a switch between its versions, matched by address, and a version without that page shows turned off. The reader's pick is remembered, so sidebar links on other pages go to it. Previous and next stay in the version. Import fills variants when sibling folders share most of their pages.

sidebar_title gives a page a shorter name in the sidebar, and the page keeps its title. Imports fill it from Next.js nav_title, Mintlify sidebarTitle and Docusaurus sidebar_label.

A note with unlisted: true is published at its address, in search and as Markdown, but stays out of the sidebar and previous and next. Imported pages the original navigation didn't list come in this way.

Pages that aren't articles

  • A note with layout: home is a landing: the site's name (or the note's own title), its description, up to three actions as buttons ("[[Note|Label]]" or "[Label](https://…)"), the note's text, then a card for each top-level folder. No sidebar. Import makes one and leaves the old home as a page.
  • A folder called Changelog (or Release notes, Releases, What's new, Updates) is one link in the sidebar. Its page shows the folder's own note, then every entry newest first by date (or a month and year at the start of the title), each titled with a link to its own page. Its headings step down a level so On this page lists only the entries.

On every docs page

  • npm and npx commands in a shell code block show as pnpm, npm, yarn and bun tabs. They switch together and the reader's pick is remembered. A block with anything else in it stays as written.
  • Code marked collapse (```tsx collapse demo.tsx) folds behind View code when it is longer than 12 lines.
  • A preview block shows Markdown or HTML as it looks, with its source under View code.
  • Step titles are headings, so On this page lists them. It marks the heading you last scrolled past, and the last one at the bottom of the page.
  • Pictures open full screen with a click or Enter. Escape, a click or Close puts them back. Pictures inside links, cards and demos don't.
  • Previous and next sit beside Copy page, and again at the bottom.
  • Search opens with ⌘K or /. The header has a light and dark switch, remembered on the reader's device. On phones the page list opens from the menu button in the header.

Settings

In .hatch/site.json, next to the usual fields. Publish shows them under Docs.

FieldWhat it does
logo, logoDarkPictures in the vault for the header. The dark one is used in dark mode.
accent#rrggbb. Links, the page you're on and the current section use it. Anything else is ignored.
linksUp to six { label, url, primary } on the right of the header. primary makes it a button. Only http(s), mailto and relative links are kept.
tabsTop-level folders as tabs.
partsThe parts around each page: copyPage, pageSteps (the arrows by the title), pager, toc and breadcrumb (the folders above the title). false leaves one out and the page closes up around it. A component name from .hatch/components draws it in its place, given prevTitle, prevLink, nextTitle, nextLink, title and markdown. A note's hide: [pager, toc] leaves parts out on that page.
transitionstrue cross-fades pages as readers move between them (Settings, Fade between pages). Off by default. Readers who ask their device for less motion never see the fade.
variantsFolder names that are versions of the same pages, default first, like ["Radix UI", "Base UI"].
faviconA picture in the vault for the browser tab. Falls back to the logo.
cssA CSS file in the vault, loaded after the theme.
footer{ links: [{ label, url }], credit }. credit: false leaves out Made with Hatch.
editUrlAdds Edit this page under each page. {path} becomes the note's vault path.
lastUpdatedShows when each page last changed, from its updated property or the file's time.
redirects{ from, to } pairs. Each from becomes a small page that sends people on, keeping a #section in to. A real page is never replaced, and a redirect to itself, .. or a script link is dropped. A Mintlify import brings its redirects, apart from wildcards. On a Hatch server, an old address with .html on the end (VitePress, Docusaurus) moves to the page’s clean one with a 301, so no redirects are needed for those.

When Hatch saves .hatch/site.json it starts it with "$schema": "./site.schema.json" and writes that schema next to it (packages/publish/src/siteSchema.ts). Editors like VS Code then autocomplete every key, explain it on hover and flag a misspelled one, and coding agents can read what the file takes. Adding a setting to SiteConfig without describing it in the schema is a type error.

For AI tools

Every docs page is also served as Markdown at its address with .md on the end, and all of them together in llms-full.txt. llms.txt links the .md files. The Markdown is made from the note's own text with only what the page shows: no properties, no %%comments%%, no collections or forms, and links to notes that aren't published become their names. The Copy page button copies it, and its menu opens it or hands it to Claude or ChatGPT.

Importing from Mintlify, Fumadocs, Docusaurus, Starlight and VitePress

Import (packages/import/src/docs.ts) takes a .zip of the docs folder. To move a whole site in one step, with a report of what needs a look, see migrate-docs.md.

  • MDX components become Hatch ones: callouts (<Note>, <Warning>, <Callout type>, <Aside>, <Admonition>, :::tip), <Steps> and Supabase's <StepHikeCompact>, <Tabs> with <Tab>, <TabItem> or <TabPanel>, <CodeGroup> (tabs of code), cards (<CardGroup>, <CardGrid>, <Card>, <LinkCard>, <Tile>), <LinkButton> (a button), <FileTree> and <Tree> (a file tree), <Accordion> and <Details> (folded callouts), page lists (<DocCardList>) and <ParamField> (a list item). Others keep their text and are named in the summary. The alias table is docsMore.ts.
  • Shared text comes in where it's used: Mintlify snippets imported into a page, and Supabase's <$Partial>.
  • The navigation becomes numbered folders and order: docs.json or mint.json for Mintlify (with its $ref files), meta.json or meta.ts for Fumadocs, sidebars.js (with page ids), _category_.json and sidebar_position for Docusaurus, numbered folders like Next.js's 01-app, the sidebar in .vitepress/config for VitePress and in astro.config for Starlight. The JavaScript is read as a plain literal, never run (docsJsNav.ts). Pages the navigation doesn't name go in "Not in the navigation", marked unlisted.
  • One language comes in: Mintlify's default (or English), and for the others, folders named for a language whose pages match the top-level ones, and pages named with a language (page.ja.mdx) beside the original, are left out. The summary counts them.
  • Links between pages become [[links]]. The home page (index, introduction or overview) becomes index.md.
  • From docs.json: the name, primary color, logos, navbar links and button, and tabs become the site's settings, if the vault has no site yet. VitePress, Starlight and Docusaurus give the title. Heading ids ({#install}) and Docusaurus's highlight-next-line comments are dropped.
  • OpenAPI pages don't come over yet. The summary says so.

Seeing a page while you write

Any note the site publishes gets a Site tab in the side panel (sitePagePanel.tsx). It shows the note as its page on the site and updates a moment after each change, at the same scroll position, the way Vite's hot reload updates an app without a full refresh.

  • Only that page is written on each change: buildSite(vault, config, { only: new Set([path]) }). The rest of the site is still read, so the sidebar, search and links are the same as in a full build. On a 1,000-page docs site that is about 0.5s instead of 2.5s.
  • Two frames take turns (components/SitePage.tsx). The new version draws in the hidden one at the reader's scroll position, then swaps to the front, so the page never flashes blank.
  • A link to another page of the site opens that note. Links off the site open in the browser.