Hatch

Moving a docs site to Hatch

On this page

This is the guide for moving a Mintlify, Fumadocs, Docusaurus, Starlight, VitePress, Nextra or Next.js-style MDX docs site into Hatch, written so an agent can do the whole move from one prompt. Every page keeps its address, its place in the sidebar, its components and its look.

The one command

npx tsx packages/publish/src/migrate-cli.ts <docs folder or .zip> <vault folder> [--folder Name] [--site out-dir]

(Installed, the command is hatch-migrate.) It:

  1. Reads the docs folder, leaving out node_modules, .git, build output (.next, dist, build, out, .docusaurus, .source) and files over 25 MB.
  2. Turns Fumadocs <auto-type-table> tags into prop tables, using the site's own fumadocs-typescript. Install the site's packages first (pnpm install in the site) or those tables are left out and listed in the report.
  3. Imports it into the vault, in a folder named after the site (or --folder).
  4. Writes the site settings to .hatch/site.json, if the vault has no site yet: name, logo, dark logo, tab icon, accent color, tabs, header links and button, footer links and redirects.
  5. Builds the site once to check it, and writes it to --site if you give one.
  6. Saves a report to .hatch/migration-report.md and prints it.

In code, migrateDocs(vault, files, { folder }) from @hatch/publish does the same and returns the report. The app's Import dialog uses the same settings step (importedSiteConfig).

Prompt for an agent

Move the docs in <path> to Hatch. Run hatch-migrate <path> <vault> --site /tmp/site, then read .hatch/migration-report.md and fix everything under Needs a look, using docs/migrate-docs.md. Serve /tmp/site and open each kind of page next to the original site, light and dark, desktop and phone. Fix any difference and run it again until there are none.

What comes over

In the sourceIn Hatch
<Note>, <Info>, <Tip>, <Warning>, <Check>, <Danger>, <Callout type>, <Aside>, <Admonition>, :::tipA callout, > [!tip] Title
<Accordion>, <Details>, <details>, :::detailsA folded callout, > [!faq]- Title
<Steps> with <Step>, or headings inside <Steps>, Supabase <StepHikeCompact>A steps block
<Tabs> with <Tab>, <TabItem>, <TabPanel> or <TabsContent>, ::: code-groupA tabs block. Install commands become one tab per package manager
<CodeGroup>A tabs block of code, named by file name. A single block stays a plain code block
<Card>, <CardGroup>, <Cards>, <CardGrid>, <LinkCard>, <Tile>, cards with title and hrefA cards block with the same columns
<LinkButton>, a <Button> around a linkA button block
<FileTree>, <Tree>, <Files>A files block
<ParamField>, <ResponseField>A list item: name, type, required, default
<ComponentPreview>A live demo when the import holds the built preview, and its source folded under View code
<DocCardList>, <PagesList>Cards for the pages in that folder
<Image srcLight srcDark>, <img className="dark:hidden">Two pictures, one for each mode (#gh-light-mode-only, #gh-dark-mode-only)
<video>, <iframe>, <YouTube>A link Hatch shows as a player
Code fence title=, {1,3-5}, showLineNumbers, wrap, // [!code ++]The same: file name, marked lines, line numbers, wrapping, added and removed rows
Snippets, <$Partial>, imported MDXTheir text, where they're used
slug, numbered names (01-intro), route groupsThe same address, in a slug property when the vault path would give another
sidebar_label, sidebarTitle, nav_titlesidebar_title
Mintlify redirectsSite redirects
Pages the navigation doesn't nameunlisted: true: published and searchable, not in the sidebar

The full alias list is in packages/import/src/docs.ts (element) and docsMore.ts (moreElement).

What needs a hand

The report's Needs a look section names each component with no Hatch match, how often it appeared and on which pages. Its text came over, but not its look. For each one:

  1. If a Hatch block does the same job (see the table above and The blocks in components.md), rewrite it as that block.
  2. If it's the site's own component and the look matters, make it a custom component in .hatch/components (Your own components in components.md). One component fixes every page that uses it.
  3. If it was decoration, leave the text.

Other things the report can name:

  • Links that go nowhere. Usually pages outside the docs (a blog, the app, an API reference). Write them as full addresses, or import those pages too.
  • OpenAPI pages. Not imported yet. Link to the reference where it lives.
  • Other languages and versions. One language and the current version come in. The report counts what was left out.
  • Blank pages. Pages that were only a component Hatch can't run come in unlisted, so nothing empty shows in the sidebar.

Checking it looks the same

Serve the built site (npx serve /tmp/site) and open these next to the original, light and dark, at 1280px and 390px:

  • The home page, and the longest page.
  • A page with code tabs, a page with steps, a page with cards, a page with callouts.
  • The sidebar with a deep group open, and search.

If the original's accent color, fonts or logo look different, set them in .hatch/site.json (accent, logo, logoDark, css for a stylesheet in the vault). The settings are in docs-sites.md.