Book for Dune
Faithful port of hugo-book (MIT © Alex Shpak — see LICENSE).

Demo: https://themes.getdune.org/book
Tags: dune-theme, docs, sidebar, faithful
Install
dune theme:install jsr:@dune/theme-book@1.0.0 --activate
Or by hand, in config/site.yaml:
themes:
- name: book
src: jsr:@dune/theme-book@1.0.0
theme:
name: book
src: jsr:@dune/theme-book@1.0.0
The stylesheet is the upstream SCSS bundle compiled as-is (defaults,
normalize, utils, main, print, markdown, shortcodes, custom — in Hugo's
bundle order), so pages match hugo-book pixel-for-pixel. Templates reproduce
baseof.html and the docs/ partials 1:1.
For a Dune-native take on the same design (curated colour schemes, lighter config), see Caravan. Full deviations-from-upstream detail and a config walkthrough are in the live demo's Using Book section.
Templates
| Template | Upstream layout | Notes |
|---|---|---|
default |
baseof.html + single.html |
sidebar filetree, mobile header, right ToC, prev/next footer |
section |
— (Dune collection indexes) |
page body + linked child list; upstream list.html is content-only |
error |
404.html |
drifting-words hover effect; rendered by core for 404/500 |
search |
— (no upstream page) | results page for Dune's /search route |
Shortcodes → MDX components
Hint, Details, Tabs/Tab, Columns, Button, Steps, Katex,
Mermaid — usable in .mdx content; markup identical to the upstream
shortcodes. KaTeX and Mermaid assets are bundled in static/ like upstream.
Configuration
Admin-editable (config_schema), matching the upstream Book* params:
book_theme (auto/light/dark), book_search, book_toc, book_logo,
book_section (route of the section shown in the sidebar; * for all),
language_labels (code/name — see Deviations), copyright.
Per-page frontmatter: bookToC: false disables the ToC for that page.
Regenerating the CSS
static/book.css is dart-sass output of an entry file that @imports the
upstream partials in assets/book.scss order (defaults, variables, normalize,
utils, main, fonts, print, markdown, shortcodes, custom) followed by the three
theme mixins under :root[data-book-theme=…] selectors. Compile with
npm:sass using loadPaths: [hugo-book/assets, hugo-book/assets/plugins].
Deviations from upstream
- Theme selection is a
data-book-themeattribute on<html>driven by theme config; upstream bakes one theme mixin into the CSS at build time. All three variants (light, dark, auto) are compiled intobook.css. - Sidebar filetree and prev/next are server-rendered from
TemplateProps.navAll(the full page index); only the live search box is an island. - Search uses Dune's server-side
/api/searchinstead of a Fuse.js client-side index; same input/results markup in the sidebar, including/and ⌘/Ctrl+K focus shortcuts from upstreamsearch.js. - Heading ids are generated by the theme (marked doesn't emit them);
the right-hand ToC is built from h2–h4 like Hugo's
.TableOfContents. - Page titles are rendered from frontmatter when the markdown body
doesn't already open with an
<h1>— Dune fixtures keep the title out of the body; upstream exampleSite puts# Titlein the content itself. - Section indexes (
template: section) also list child pages from a Dunecollectionblock; upstreamlist.htmlis content-only. - Language switcher (
book-languagesdropdown in the sidebar, plushreflangalternates) is driven by Dune's per-pagetranslationsprop; it lists only languages the current page exists in. Labels default to the language code; set thelanguage_labels: nametheme option for native names viaIntl.DisplayNames("Deutsch", "日本語"). A locale string keyed by the language code overrides both. Upstream's fallback to home-page translations (BookTranslatedOnly=false) is not reproduced. - Not ported: GitInfo footer (last-modified / edit-this-page links —
no Dune equivalent), comments partial,
service worker / PWA manifest,
bookCollapseSectioncollapsible menu entries,asciinema/openapi/i18n/html/image/ deprecatedsectionshortcodes, taxonomyterm.html, posts layouts.