Trailhead: moving from Docusaurus
In your terminal ssqch docs --from docusaurus
Docusaurus sites are React apps that happen to render documentation; ssqch builds the same documentation as static HTML that needs no JavaScript to read. The move is mostly mechanical for Markdown pages, and takes a decision for each React component: an Edge component, a container, or client-side JavaScript that stays.
Two examples are inspired by a real-world site: versioned-docs (versions, sidebars, tabs, a blog with authors) and component-docs (components in place of MDX, live examples).
The config
| Docusaurus | SiteSquatch |
|---|---|
docusaurus.config.js | ssqch.config.js |
docs/, blog/, src/pages/ | Folders in the input (src/docs/, src/blog/), and templates for the other pages |
static/ | passthrough: [{ "static": "." }] |
@docusaurus/plugin-sitemap | sitemapPlugin({ url }) from ssqch/sitemap |
@docusaurus/plugin-client-redirects | redirectsPlugin({ redirects }) from ssqch/redirects (real pages or _redirects lines, not client-side redirects) |
| Algolia DocSearch, or a local search plugin | Pagefind after the build: afterBuild: { run: "npx -y pagefind --site dist" } (see the docs-sidebar example) |
themeConfig.prism | markdown: { highlight: true }; colors from /highlight.css and its --hl-* properties |
prism.additionalLanguages | Nothing to list for most: about 200 languages are built in, under Prism's names too (jsx, tsx, jsonc, bash). One that isn't is plain text, and the build warns once a build for each, with the page: give it markdown: { highlight: { languages } }, as a function that returns tokens, an alias ({ "js-nocheck": "js" }) or a .sublime-syntax file (ssqch docs languages) |
onBrokenLinks: "throw" | linksPlugin(): broken links and anchors fail production builds |
i18n | Not yet |
Several docs instances (@docusaurus/plugin-content-docs with an id each) | A folder for each in the input, each with its own directory data and sidebar data |
docs: { path: "../docs" }, content outside the site's folder | A link in the input to it (ln -s ../../docs src/docs): the build reads through links, ssqch serve watches what they lead to, and lastModified: "git" dates the pages by their commits |
remark-math with rehype-katex | markdown: { math: { render: "katex" } } with the site's own katex (npm install -D katex): every formula is rendered while the site builds, as rehype-katex does, and the layout links KaTeX's stylesheet (Math with KaTeX or MathJax). With math: true alone, the TeX stays for a script in the page |
remarkPlugins, rehypePlugins | ssqch's Markdown has its own steps: markdown.preprocess for the source, render hooks for headings, links, images and fences, and transforms for the HTML. A remark plugin that only changes the text can run in preprocess with unified; most become a hook |
themeConfig.prism.theme | The highlighter's colors are the --hl-* properties of /highlight.css: set them for a Prism theme's colors, or highlight: { css: false, classes: "prism" } and the theme's own stylesheet |
Docs, versions and sidebars
| Docusaurus | SiteSquatch |
|---|---|
versioned_docs/version-1.0/ and docs/ (next) | src/docs/1.0/ and src/docs/next/, each with directory data ({ "version": "1.0", "layout": "doc.jinja" }) |
versions.json | _data/versions.json, for the version switcher |
sidebars.js | _data/sidebars/<version>.json, or a _data/sidebars.js that builds one from it: navTree reads entries with title and url (children under children), so Docusaurus's doc ids become their URLs and labels their titles, a few lines of map. navTree(sidebar, page.url) marks the current page, navPager gives previous and next, navBreadcrumbs the trail. |
Autogenerated sidebars (sidebar_position) | nav: { parent, order } front matter and pagesTree(collections.docs) |
id, slug | permalink. Docusaurus's own rule (a number prefix dropped, a page's id as the last part of its URL, index, README and a folder's own name as the folder, and slug beating them, from the folder or from the docs' base when it starts with /) is a computed permalink in the docs' directory data: Docusaurus's URLs, below |
sidebar_label, sidebar_position | The sidebar data, or nav: { title, order } |
hide_table_of_contents | A front-matter flag your layout checks before toc(page.headings) |
tags | tags |
last_update (git) | lastModified: "git" in the config, then page.lastModified |
| A page with no date of its own | Its file's time in ssqch, which a checkout or a save moves: dates and the order of lists change from one build to the next, and on each save ssqch serve renders the pages that show it (every page that reads collections, when the site's code sorts by dates). dateFallback: "git" gives it its last commit's date (ssqch scout counts the pages that have none) |
Docusaurus's URLs
In the docs folder's directory data (src/docs/docs.data.js), a permalink that follows Docusaurus's rule: the number prefixes dropped (01-tutorials/02-basics.md is /docs/tutorials/basics/), a page's front-matter id in place of its file's name, an index.md, a README.md or a file named as its folder (guides/guides.md) as the folder's own page, and a slug that beats all of them, from the page's folder, or from the docs' base when it starts with /:
import path from "node:path";
export default {
// Where the docs are served: Docusaurus's `routeBasePath` (`/docs` by default).
instanceBase: "/docs",
computed: {
permalink: (d) => {
const parts = d.page.filePathStem.replace(/(^|\/)\d+-/g, "$1").split("/");
const name = parts.pop();
const folder = parts.join("/");
if (d.slug) return path.posix.join(d.slug.startsWith("/") ? d.instanceBase : folder || "/", d.slug, "/");
const index = /^(index|readme)$/i.test(name) || name.toLowerCase() === parts.at(-1)?.toLowerCase();
return index ? `${folder}/` : `${folder}/${d.id ?? name}/`;
},
},
};
The id is the part most moves miss: a site's docs often have one that isn't their file's name (id: organizing-state in faq/OrganizingState.md, on 55 of 170 pages in one move), and a rule without it gives them the wrong address, with no broken link to say so, since the site's links go through the same rule. Compare with the old build before deciding the rule is right: ssqch diff build _site --only '**/*.html' lists the pages only one side has. A slug: / (a doc as the docs' home) is /docs/.
Markdown and MDX
| Docusaurus | SiteSquatch |
|---|---|
:::note, :::tip Title, :::warning[Title] | Containers, with the same ::: syntax: _includes/containers/note.* renders them (the title is container.args) |
<Tabs> and <TabItem value="npm"> | :::: tabs holding ::: tab npm containers (see versioned-docs) |
A code block's title="App.js" and {1,4-6} | {1,4-6} marks lines with highlight: true; title= reaches a fence hook as part of fence.info |
Live code blocks, SnackPlayer fences | A fence-<lang> hook (_includes/hooks/fence-SnackPlayer.jinja) that writes the embed |
MDX import and JSX components | The site's own components: reactPlugin() from ssqch/react, with the page's import lines and tags as they are, rendered with the site's own React (React components). Rename .mdx to .md, and alias @site/ with reactPlugin({ esbuild: { alias: { "@site": "." } } }). Docusaurus's own theme components (@theme/Tabs, @theme/Admonition) need Docusaurus's router and context and don't run outside it: tabs and admonitions are ssqch's containers (above). A component of the site's that imports one of Docusaurus's modules (@docusaurus/BrowserOnly) needs a stand-in, below. A page whose MDX goes further ({expressions} in text, export) renders with MDX itself: MDX as written |
A partial (import Intro from "./_intro.md", then <Intro />) | An include: the partial in _includes/, and {% include "intro.md" %} where the tag was (a Markdown page runs through Jinja first; not with markdownEngine: false) |
<!-- truncate --> in blog posts | <!-- more -->, then page.excerpt |
authors.yml | _data/authors.json (or .yml), looked up by the post's authors |
{#custom-id} headings | The same |
{/* a comment */} in MDX | <!-- a comment --> |
Swizzled theme components (src/theme/) | ssqch's own layouts and includes in the site's template language; the swizzled component's markup is the place to start |
React pages
Pages in src/pages/*.js become templates in any of ssqch's languages. Interactive parts (a playground, a live demo) keep their React: reactPlugin({ hydrate: { Playground: "visible" } }) renders them at build time and runs them in the browser as islands, with a script only on the pages that have one (React components). Or ship them as custom elements with elementsPlugin() from ssqch/elements (the islands example).
Docusaurus modules in a site's components
A site's own components often import a piece of Docusaurus (@docusaurus/BrowserOnly, @docusaurus/Link, useColorMode from @docusaurus/theme-common), which esbuild can't find outside a Docusaurus build: reactPlugin() stops with Could not resolve "@docusaurus/BrowserOnly" and the component's line. Give each a stand-in of a few lines with esbuild.alias. BrowserOnly, which renders its children only in the browser:
// stand-ins/BrowserOnly.jsx
import { useEffect, useState } from "react";
export default function BrowserOnly({ children, fallback = null }) {
const [browser, setBrowser] = useState(false);
useEffect(() => setBrowser(true), []);
return browser ? children() : fallback;
}
reactPlugin({
hydrate: { VideoEmbed: "visible" },
esbuild: { alias: { "@docusaurus/BrowserOnly": "./stand-ins/BrowserOnly.jsx" } },
}),
@docusaurus/Link is an <a> (export default ({ to, href, ...rest }) => <a href={to ?? href} {...rest} />), and useColorMode a hook that reads the page's own theme switch. A component built on Docusaurus's context throughout (its navbar items, anything that reads useDocusaurusContext()) is part of the theme: it becomes ssqch's layouts and includes.
MDX as written
For pages whose MDX does more than import components and use their tags ({props.title} and other expressions in the text, export const), render .mdx with the site's own MDX and React as an engine of its own (npm install -D @mdx-js/mdx react react-dom):
import { pathToFileURL } from "node:url";
import { evaluate } from "@mdx-js/mdx";
import * as runtime from "react/jsx-runtime";
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
export default {
templateFormats: ["mdx", "md", "jinja"],
engines: {
// The front matter is gone already; `path` lets a page's own imports resolve.
mdx: async (source, data, { path }) => {
const { default: Page } = await evaluate(source, { ...runtime, baseUrl: pathToFileURL(path) });
return renderToStaticMarkup(createElement(Page, { ...data }));
},
},
};
The page's data is its props (# {props.title}), and layouts are ssqch's as for any page. What it doesn't do: the pages are HTML only (nothing runs in the browser), the components a page imports have to be JavaScript Node can import (a .jsx or .tsx file needs compiling first, as reactPlugin() does for its own), and an error names the page but not its line. evaluate's remarkPlugins option runs the site's own remark plugins.
What byte for byte means for Docusaurus
A move that keeps Docusaurus's React and its bundles can't be byte for byte: rspack names its chunks and the page's CSS by hashes of what's inside them, and its main bundle has the checkout's path in it, so even two Docusaurus builds of the same commit in different folders differ on every page. Compare with the bundles' names left out, and only the pages:
ssqch diff .cache/ssqch/baseline/ref-1 dist --exact --ignore '(styles|runtime~main|main)\.[0-9a-f]{8}' --only '**/*.html'
What ssqch builds itself (its own templates, Markdown and highlighting) is a different theme's markup, so measure it with ssqch diff --text, which compares each page's words.
Starting point
ssqch init --starter docs creates a docs site with a sidebar, a table of contents, tabs, notes and search, to move your pages into. To check the move, build both sites and run ssqch diff build dist.
A file whose changes are all dates or years says only dates changed (2025 -> 2026), and the end of the report counts them (All 12 changed files differ only in dates or years). The usual cause is a page with no date of its own (in Docs, versions and sidebars), dated by its file's time: give it a date or set dateFallback: "git", and write a copyright year as {{ now() | dateformat("%Y") }}.