Book Export
PDF Book Export
The browser book exporter builds a complete book PDF from a Hugo site. It assembles a book manifest, loads Hugo-rendered chapter bodies in Chromium, composes pages, writes the PDF, and records diagnostics.
Canonical Commands
Final two-pass export:
npm run browser:export:book-pdf -- \
--site-root /path/to/site \
--url http://127.0.0.1:1313/ \
--output /path/to/book.pdfFast iteration:
npm run browser:export:book-pdf -- \
--site-root /path/to/site \
--url http://127.0.0.1:1313/ \
--output /tmp/book.pdf \
--fastWatch mode with a local Hugo server:
npm run browser:watch:book-pdf -- \
--site-root /path/to/site \
--output /tmp/book.pdf \
--start-hugoExport Modes
--document-kind thesiskeeps formal title/frontmatter/recto behavior.--document-kind articlekeeps the same rendering and pagination machinery but uses compact article-style first-page flow.--templateand--latex-modeare accepted aliases for document kind.articleandjournalnormalize to article behavior; other values use thesis behavior.--fastskips slower finalization passes and is for iteration, not final output.
The exporter writes a PDF plus adjacent build/diagnostic data so an export can be reproduced and audited.
If --output is omitted, the default output is
build/pdf/browser/phd-double-spread.pdf.
Common Options
--paper a4|a3and--landscapechoose page geometry.--headedopens a visible browser.--profileenables profiling output.--diagnosticswrites diagnostics alongside the PDF.--generated-index on|offcontrols the simple generated index.--page-planis the current default book-export preparation path.--legacy-paginationfalls back to the older pagination path.--hugo-host,--hugo-port, and--draftscontrol the local Hugo server when the exporter starts it.
The final path requests tagged PDF and outline output from Chromium, then stamps
page labels, metadata, headers, and footers. The adjacent .build.json records
command, Git/runtime details, and summary diagnostics.
Watch mode keeps one live preview page and one export page, with separate preview/export queues and debounce behavior so long PDF writes do not block the headed preview.
Inputs
The exporter expects a normal Hugo site structure. Root front matter supplies book metadata and options; section and page front matter control order and semantic roles. Hugo render hooks supply print metadata before the browser pass runs.
Files To Read
scripts/export-site-book-pdf.jsscripts/book-pdf/browser-page-builder.jsscripts/book-pdf/browser-book.cssdocs/pdf-book-authoring-contract.md