Hyperbook Documentation

Translations

A book can be built in several languages. Every page keeps one address in all of them: the source language is served as before, every other language below its code (/setup and /de/setup). The language menu in the header leads to the same page in another language.

Turning it on

List the languages in hyperbook.json. The first one is the source language, the one the book is written in:

{
  "name": "Handbook",
  "languages": ["en", "de"],
  "translations": {
    "de": {
      "name": "Handbuch",
      "description": "Ein Handbuch"
    }
  }
}

translations holds the options that differ in a language: the name, the description, the links in the header. Objects are merged with the other options, key by key; a list (like links) replaces the list of the source language.

Translating a page

A translation sits next to its page, with the language before the extension:

book/
  index.md
  index.de.md
  setup.md
  setup.de.md
  notes.md          (no translation yet)

The translation's frontmatter is merged over the page's, and its text replaces the page's text. So a translation only needs what is different, usually the name:

---
name: Einrichtung
---
 
# Einrichtung
 
Installiere es.

The index, permaid, scripts and everything else the translation does not set come from setup.md. The navigation is the same in every language and is sorted by the source language's names.

A page without a translation shows its source text, with a notice that it is not translated yet. Set translate: false on a page that stays in the source language on purpose, like a changelog: it is shown without the notice.

The glossary works the same way (glossary/sprite.de.md), and so do snippets (snippets/hint.de.md.hbs is used instead of snippets/hint.md.hbs in German).

Pages made from data

A page made from a JSON or YAML file and a template is translated with a data file of the same name: api.de.md.json next to api.md.json. It only needs the fields that are translated; they are merged over the page's data before the template runs:

{
  "description": "Bewegt die Figur."
}

Templates stay the same in every language. The words in them come from templates/strings.json and, for a language, templates/strings.de.json, through the t helper:

## {{t "examples"}}
 
{{t "made-for" name=author}}
{ "examples": "Beispiele", "made-for": "Gemacht fΓΌr {name}" }

A word missing in a language's file is taken from strings.json, a word missing there is shown as its key. {{@language}} is the language a template is rendered in. A template that needs a layout of its own in a language can have a translation too: templates/method.de.md.hbs.

Readers and their language

A reader who opens a page of the source language is sent on to the same page in the language their browser prefers, if the book has it. Once they choose a language in the language menu, that choice is kept (in their browser only, not in a cookie) and wins over the browser's. A link to a page in another language is never redirected: a German link someone shared stays German.

Set "detectLanguage": false to leave readers in the language of the link they followed.

Search engines find every page in every language through hreflang links.

Keeping translations up to date

A translation can say which version of its page it translates:

---
name: Einrichtung
translationOf: 3fa29c1b07
---

hyperbook check lists translations without translationOf (with the value to add), translations whose page changed since (with the new value, once the translation is updated) and translation files of pages that do not exist. It checks the links in translations too.

Translations

Create Shareable URL

Select Sections

✎ GitHub© Copyright 2026 by OpenPatch