Move a book from mdBook
Six Colliery books moved this way: Kairos (the first, KAIROS-T-0389), Squire, Arawn, GraphQLite, Mimir and Brokkr. These steps come from those moves.
Procedure
Section titled “Procedure”-
Copy the starter into the repository, as in Start a docs site. Move the old
docs/folder away first, for example todocs-mdbook/. -
Convert the pages with the converter that the theme ships:
Terminal window cd docs && npm ci && cd ..npx --prefix docs starlight-aurora-from-mdbook docs-mdbook/src docs/src/content/docs > sidebar.jsonFor each page, the converter:
- makes the first
# Headingthe front-mattertitle, and removes it; - removes a
---rule right after that heading (with front matter, it would swallow the first section); - rewrites links to other pages (
page.md#anchor,page.html) as relative routes (../page/#anchor), which work under the Pages base path; - writes
README.mdasindex.md.
It writes a Starlight sidebar made from
SUMMARY.mdtosidebar.json, with the parts, the##groups and SUMMARY’s labels. - makes the first
-
Put the pages in their Diátaxis sections (tutorials, how-to, reference, explanation), and paste the sidebar into
docs/astro.config.mjs. If a page moves to a new folder, change its slug in the sidebar and add its old address to the redirects (step 6). -
Put images in
docs/src/assets/images/, outside the content folder, and change their links. Do not link to a file insrc/assetswith a plain link: it does not resolve. Link to the page that shows the image, or put files to link to indocs/public/. -
Set the theme’s options in
docs/astro.config.mjs. The starter turns off titles taken from a code block’s first line (a first-line comment such as# Expected: /home/…would become the block’s title and disappear). -
Keep the old addresses working. Add the redirect integration:
import mdbookRedirects from 'starlight-aurora/mdbook-redirects';integrations: [mermaid({ theme: 'dark', autoTheme: true }),mdbookRedirects(),starlight({ /* ... */ }),],After each build, it writes a small page at each old address (
how-to/set-up-a-board.html) that sends the reader to the new one, and keeps the#anchor.introduction.htmlandprint.htmlgo to the home page. AREADME.mdpage needs no redirect: mdBook served it asindex.html, which is still a page.Give it more addresses with
extra. They are added to the defaults, andnullremoves a default:mdbookRedirects({extra: {'intro.html': './', // the old home page'getting-started/installation.html': '../how-to/installation/', // a page that moved'print.html': null, // no redirect for print.html},})Each target is relative to the old address. It never writes over a page of the site.
-
If the repository has an
.angreal/task_docs.pyalready, merge the starter’sdocs buildanddocs serveinto it. The starter finds the repository root withPath(angreal.get_root()).parent; use the repository’s own root helper if it has one. -
Remove
book.toml,SUMMARY.mdand the old theme folder. -
Check the build, its links, and the theme:
Terminal window cd docs && npm run build && cd ..npx --prefix docs starlight-aurora-check-links docs/distDOCS_SITE=https://example.github.io DOCS_BASE=/my-repo npm --prefix docs run build -- --outDir dist-basenpx --prefix docs starlight-aurora-check-links docs/dist-base --base /my-repo/npx --prefix docs starlight-aurora-check-site docs/dist --hyperSee Check a site.
Publish to another repository
Section titled “Publish to another repository”The starter’s workflow publishes to the repository’s own Pages. To publish to
another repository, as Mimir does (mimir-dm/mimir-dm.github.io), keep the
build steps and replace the deploy job with peaceiris/actions-gh-pages, a
deploy token in the repository’s secrets, and external_repository. Build
with DOCS_SITE set to that site and DOCS_BASE=/ if it serves at the root.