# Roles: audience spaces, role switching and version comparison

> Accepted design for native Hugo roles in OINK. A role becomes an audience space with its own derived shape of languages and versions, a role switcher on C, role-aware links and configuration, confined outputs and browser state for protected spaces, and a Duo View that V opens on another version of the same page.

---

LLMS index: [llms.txt](/llms.txt)

---

> [!NOTE] Accepted design, local implementation (2026-12-04)
> The v2 design is accepted. The candidate implementation is available in the
> sibling theme checkout. Normative behavior now lives in the
> [Shell](/docs/design/shell/#roles) and
> [Architecture](/docs/design/architecture/#version-links) contracts; user setup
> is documented in [Spaces (roles)](/docs/customize/roles/).
> The December 5 prerelease review retained two shortcut fallbacks. Without another space, `C` opens commands. Without a version counterpart, `V` cycles the version menu.

| Record | Value |
| --- | --- |
| Status | Accepted v2 design (2026-12-04), implemented in the local release candidate; all design decisions settled ([decision log](#decision-log)) |
| Owner | OINK maintainers |
| Owner decisions | `C` switches roles and `\` keeps opening commands; `V` opens Duo View on another version instead of cycling versions; one reader serves both keys, switching axes in place when the other key is pressed; role-autonomous defaults, transitive peer discovery, automatic `sitemap.xml` emptying for `index: false`, and history-scope confinement for unlisted roles |
| Baseline | Hugo 0.171.0 (roles since 0.153.0); theme `main` |
| New public API | `params.ui.roles`, `params.ui.role_menu`; a `roles` filter on configured menu entries, palette commands, page context links and `params.versions` entries; actions `switch_role` and `compare_versions`; link state `role`; shortcut rows `role` and `duo-version` |
| Changed public behavior | `C` and `V` bindings; Duo View targets, axis switching and pane headings; where a prefixed role publishes its search index; `robots` and `sitemap.xml` for roles with `index: false`; history storage scope for unlisted roles |
| Affected contracts | [Shell · keyboard](/docs/design/shell/#keyboard-shortcuts), [Shell · translation comparison](/docs/design/shell/#translation-comparison), [Shell · version menus](/docs/design/shell/#archived-banner), [Architecture · outputs](/docs/design/architecture/#outputs-and-runtime), [Architecture · version links](/docs/design/architecture/#version-links), the [document comparison decision](/docs/design/decisions/document-comparison/), the configuration reference and generated schemas, all 32 locales |
| Related | [Gap review 2026-12-02](/docs/design/research/2026-12-02-gap-review/#hugo) lists roles as an unused Hugo capability. The [Spec boards](/docs/design/proposals/spec-boards/) draft describes content an internal role could hold. Follow-up needed in `oink-cli` (`internal/app/authoring.go`) to accept `sites.matrix.roles` mounts |

## Summary {#summary}

A Hugo role is a third site dimension beside language and version. It is meant
for audiences: the same project builds a public manual and, under `/spec/`, an
internal one. Hugo gives a role a name, a weight and an output prefix, nothing
else. It has no access control, no label, no per-role configuration, and it
builds every combination of language, version and role whether or not the
combination has content.

This proposal makes roles usable in OINK without a second configuration
authority:

1. **Content defines each role's autonomous shape.** Every role derives its
   non-empty sites, versions, languages, default version, default language and
   entry routes from its mounted content. Combinations without rendered content
   files are *empty sites*; OINK excludes them from every switcher and renders
   their HTML home as a redirect.
2. **Roles get a reader interface across every breakpoint.** `params.ui.roles`
   gives each role a label, an icon, whether other roles list it, and whether
   search engines index it. The controls appear in Space, language, version order,
   `C` cycles roles, and non-default spaces retain a compact compass
   indicator even on mobile or when no other role is listed.
3. **Links and site configuration understand roles.** A non-default role falls
   back to the default role across version and default-language boundaries;
   explicit `/<role>/...` links adapt to the target role's available versions
   and languages; menus, palette commands, page links and external versions
   filter by `roles` *before* resolving targets.
4. **Protected roles leave zero public footprint.** Everything OINK generates
   for a prefixed role stays under that role's directory—including search
   indexes, `sitemap.xml` emptying when `index: false`, `llms.txt` isolation,
   role-keyed template caches, static JS chunks and `localStorage` browsing
   history—so one server rule protects it, or a Hugo environment omits it.
5. **`V` opens Duo View on another version.** The reader that `B` opens on a
   translation gains a version axis over the page's full transitive equivalence
   class of counterparts, with linked version and language menus, independent
   axis preferences, and direct `B` ↔ `V` axis switching.

## Background and evidence {#background}

### What Hugo does {#hugo-behavior}

The rows below were verified with scratch builds on Hugo 0.171.0:

| Behavior | Observation |
| --- | --- |
| Configuration | `roles` takes a `weight` per role; `defaultContentRole` and `defaultContentRoleInSubdir` choose the default and its directory. `Site.Role` has only `Name` and `IsDefault` ([roles](https://gohugo.io/configuration/roles/), [Site.Role](https://gohugo.io/methods/site/role/)) |
| Access control | None. Hugo expects authentication outside Hugo, by directory ([PR #13679](https://github.com/gohugoio/hugo/pull/13679)) |
| Output paths | `/<role>/<version>/<language>/`; default values take no directory unless their `…InSubdir` option is set |
| Assignment | A mount's or a page's `sites.matrix` chooses roles, versions and languages; `_role_<name>_` in a file name since 0.161.0. Content without `sites` belongs to the default role only |
| Dimensions | Independent. A mount can give a role one language and one version while the default role has several of each |
| Full matrix | Every combination is a site. Two roles, three versions and two languages make twelve sites; a Chinese-only role still gets a home page, `404.html`, `sitemap.xml` and taxonomy pages in every other cell unless suppressed |
| Cascade on home | A blanket `cascade` setting `build: {render: never}` on `languages: ['**', '! zh']` also suppresses `(spec, defaultVersion, en)`'s `home`, removing `/spec/index.html` and causing `/spec/` to 404 unless `kind` excludes `home` |
| `Rotate "role"` | Returns existing peers of a page in other roles with the *exact same* language and version only |
| `sites.complements` | Lends pages to another site's lists only. `GetPage` returns nil and `relref` fails with `REF_NOT_FOUND` in the borrowing site |
| Configured menus | Apply to every role of a language. A `sites` key on a menu entry is ignored. Front matter menu entries belong to the page's own role |
| `static/` | Published at the root for every build, even through a mount whose `sites.matrix` names a role, and even in a segment build that excludes that role |
| Global resources | `resources.Get` and `resources.FromString` publish relative to the publish root (without `baseURL`'s subpath); prefixing their target with `<role>/...` confines them under that role's directory |
| Segments | `--renderSegments` writes only the selected sites, but `hugo.Sites` and `Rotate` still return the excluded ones. A segment with only `excludes` renders nothing |
| Environments | Configuration layered with `--config a.yaml,b.yaml` or `config/<environment>/` can add a role and its mounts; the other build never knows the role. Mount lists replace, they do not merge |
| Sitemaps | Each site writes its own; the root sitemap index lists only the default role and version |
| Aliases, 404 | Published inside the role's directory |
| Templates | `single._role_staff_.html` applies only to that role |

### What OINK does today {#current-oink}

Core link and site-index tables include `.Site.Role.Name`, and
`bin/check-version-links.py` builds two symmetrical roles. However, building an
asymmetric `spec` role (Chinese-only, single-version) beside a multilingual,
multi-version `public` role exposed defects across both UI and isolation:

| Area | Observed |
| --- | --- |
| Empty sites | `spec` counted as natively versioned. Its version menu offered `v4.1` and `v3.2` home pages and external archives; its language menu offered the empty English home |
| Search & chunks | Every `spec` site published `offline-search-index.spec.*.json` at the root, outside `/spec/`, including five empty-site indexes; `js/chunks/google-search-<lang>.js` baked in `absLangURL` without role or version isolation |
| Cache collisions | `backlinks-index.html`, `actions/root-order.html`, `shell/blog-index-pages.html`, `theme-color-pair.html` and `images-authored.html` omitted role/version from `partialCached` keys, risking cross-role leakage of unlisted URLs and titles |
| Links | A `spec` (`zh`) page linking to public `/docs/install/` warned as `missing`; an English public page linking explicitly to `/spec/design/storage/` missed when `spec` had no `en` site |
| Configuration & LLMS | Site menus, palette commands and `params.versions` archives appeared in `spec` and warned on missing targets; `index.llms.txt` did not filter role-scoped menus |
| Browser history | `history.js` stored all visits under `td-history:<basePath>`, exposing visited `/spec/` titles and URLs inside the public `H` history dialog |
| Interface | No role menu, no shortcut, no palette action, and no space indicator on desktop or mobile |

Meanwhile, Duo View paired only translations of the same version
(`.Translations`), while `V` cycled `switch_version` targets blindly.

## Goals and non-goals {#goals}

Goals:

- a project can hold a versioned, multilingual public manual and an
  unversioned, single-language internal space in one build;
- each role's languages, versions, default version, default language and entry
  routes follow automatically from its content, with no shape declaration;
- readers can see which space they are in across desktop and mobile, and switch
  spaces by menu, palette and `C`;
- pages can link implicitly from a non-default role to the default role (across
  version and default-language gaps) and explicitly across roles without
  spurious warnings, while warning once when a listed role links into an
  unlisted one;
- everything OINK generates or stores for an unlisted role stays confined to
  its prefix, and a public build can omit a role completely;
- readers compare a page side by side with any published counterpart across
  versions and languages in one shared Duo View.

Non-goals:

- authentication, authorization or encryption; OINK remains a static theme;
- per-role site titles, logos, presets or parameter files; roles share site
  configuration except for [scoped configuration](#scoped-configuration) and
  ordinary Hugo `cascade` front matter overrides;
- search across roles, or comparing pages across different roles;
- text diffs, changed-paragraph highlighting or line-by-line locking;
- Hugo `sites.complements`; it lends pages to lists only and breaks links;
- changing how Hugo assigns content to roles.

## Model {#model}

- **Role**: an audience space.
- **Site**: one cell of the matrix (`role × version × language`).
- **Empty site**: a site of a non-default role in which no page comes from a
  content file of that site (`.File != nil` and `.Site.Home == $site.Home`)
  that renders output (`content/renders-page.html`). The default role keeps
  today's behavior so a language whose home is built solely from Landing data
  keeps its place in menus.

`content/role-index.html` derives a six-part shape for every role that has at
least one non-empty site:

- **`sites`**: non-empty sites of the role in Hugo's order, plus a
  `"<version>|<lang>"` lookup table;
- **`versions` / `versioned`**: Hugo-ordered versions with at least one non-empty
  site; `versioned` is true when `len(versions) > 1`;
- **`languages`**: ordered languages with at least one non-empty site;
- **`defaultVersion`**: Hugo's default version if present in `versions`, else
  `versions[0]`;
- **`defaultLanguage`**: Hugo's default language if present in `languages`,
  else `languages[0]`;
- **`entry` / `entryByLanguage`**: `entryByLanguage[lang]` is `(defaultVersion, lang)`'s
  published HTML home if present, else the first non-empty site of the role in
  `lang` with an HTML home; `entry` is `entryByLanguage[defaultLanguage]` (or
  the role's first published HTML home).

For the example with English as the project default:

| Role | Non-empty sites | Versioned | Default version / lang | Entry |
| --- | --- | --- | --- | --- |
| `public` (default) | `v4.2`, `v4.1`, `v3.2` × `en`, `zh` | Yes | `v4.2` / `en` | `/` (`zh`: `/zh/`) |
| `spec` | `v4.2` × `zh` | No | `v4.2` / `zh` | `/spec/zh/` |

A role declared in `roles` that has zero non-empty sites warns once, never
appears as a target, and redirects its home to the default role's entry.

## Proposed behavior {#design}

### Configuration {#configuration}

```yaml
defaultContentRole: public
roles:
  public: {weight: 1}
  spec: {weight: 2}
params:
  ui:
    role_menu: Space            # optional; localized ui_role otherwise
    roles:
      public:
        label: Documentation
      spec:
        label: Internal spec
        icon: fa-solid fa-lock
        listed: false
        index: false
```

| Key | Type, default | Meaning |
| --- | --- | --- |
| `params.ui.role_menu` | string, localized `ui_role` ("Space", "空间") | Role menu name and `switch_role` palette title. The keyboard help uses `ui_shortcut_role`. |
| `params.ui.roles.<role>.label` | string, the role name | Text of the role in menus and the palette |
| `params.ui.roles.<role>.icon` | Font Awesome class pair, none | Icon beside the role name in the Space menu |
| `params.ui.roles.<role>.listed` | boolean, `true` | Whether other roles offer this role. Its own pages always offer listed roles so a reader can leave |
| `params.ui.roles.<role>.index` | boolean, `true` | `false` writes `noindex, nofollow` on the role's HTML and empties its `sitemap.xml` |

A language overrides `label` and `role_menu` in its own `params.ui`. An entry
for an undefined role, a non-string label, an invalid icon or a non-boolean
switch warns once and uses the default. A role needs no entry.

### Empty sites {#empty-sites}

- Empty sites are never targets of language, version or role menus, the
  palette, `X`, `C`, Duo View, `hreflang` alternates or LLMS peers, and do not
  count toward a role's versions or languages.
- `shell/search-enabled.html` is `false` on empty sites, and
  `search/index-resources.html` publishes no search index for them, so
  residual `404.html` or taxonomy pages in an empty site neither publish empty
  indexes nor fail looking one up.
- In `baseof.html` and `baseof.landing.html`, empty-site home redirection
  (`content/role-home.html`) runs *before* `version-home.html`, writing a
  redirect to `entryByLanguage[lang]` (else `entry`) with a canonical link and
  `noindex, nofollow`. Typing `/spec/` lands on `/spec/zh/`. `version_home`
  applies only to non-empty sites of `versioned` roles whose version differs
  from `defaultVersion`.
- Residual pages rendered in an empty site carry `noindex, nofollow` and an
  empty `sitemap.xml`.

### Role switching {#role-switching}

`content/role-targets.html` returns one ordered list per page, in Hugo's role
order, shared by the navbar, mobile drawers, compact subnav, footer line,
palette and `C`. For each role $R$ other than the current one, it picks the
first published HTML page among:

1. the exact peer in `(R, currentVersion, currentLang)` from `.Rotate "role"`;
2. the same logical path or a translated path in the target role, checking the
   current language, the role default, then remaining languages in Hugo order.
   Within each language, try the current edition, the role default, then the
   remaining editions in Hugo order;
3. $R$'s home in `(currentVersion, currentLang)` when that site is non-empty;
4. `R.entryByLanguage[currentLang]`;
5. `R.entry`.

Steps 3–5 carry `data-td-role-home`. A role with `listed: false` appears only
on its own pages. A role with no non-empty site never appears.

- The desktop navbar, mobile drawers and footer dock order their controls
  Space, language, version. The navbar and footer use a compass for Space.
  Hover, focus or tap opens the choices. Entries carry their role's label and icon.
- Non-default roles keep the compass in the phone bar. Other dimensions are
  available in the drawer and footer. With no alternate target a non-default role
  shows a static compass with its space name available to assistive technology.
- **Palette and keyboard.** `switch_role` is a palette choice action available
  whenever at least one other target exists. `C` cycles to the next non-active
  target, wrapping.

### Links across roles {#links}

`content/site-link.html` and `content/site-destination.html` gain symmetric
fallback and explicit resolution:

- **Fallback to the default role.** In a non-default role, a site-root path
  that matches nothing in the current role tries non-empty sites of the default
  role $D$ in the same language and edition order as the role switcher. A
  hit returns state `role` and `data-td-link="role"` without warning. The
  default role never falls back into another role, and non-default roles never
  fall back into one another.
- **Explicit role segment.** When a site-root path matches no real page, route
  or resource in the current role and its first segment names a role $R$, the
  remainder resolves in $R$, recognizing optional leading version and language
  segments. An explicit dimension is binding. Unspecified dimensions follow the
  role switcher's candidate order. The default role also accepts its logical name
  when its published URLs have no role directory. `/spec/design/storage/` from an English
  public page therefore resolves to `/spec/zh/design/storage/`. Cross-role hits
  carry state `role` and `data-td-link="role"`. A real page at that path in the
  current role always wins.
- **Cache-safe leak warning.** When a listed role resolves an explicit link
  into a role with `listed: false`, `site-destination.html` returns
  `leakedRole` as pure data and `site-link.html` (outside `partialCached`, when
  `not .quiet`) warns once per source file or configuration key and authored target URL.

### Scoped configuration {#scoped-configuration}

Configured lists filter entries by `roles` *before* resolving target URLs:

| Entry | Where `roles` goes | Default when `roles` is omitted |
| --- | --- | --- |
| Configured menu entry (and children) | `params: {roles: [public]}` | Every role |
| `params.ui.command_palette.commands[]` | `roles: [public]` | Every role |
| `params.ui.page_context_menu.links[]` | `roles: [public]` | Every role |
| `params.versions[]` | `roles: [public]` | `versioned` roles when the project has `> 1` native versions; `listed: true` roles when the project has `1` native version |

- A shared `content/role-menus.html` filters `.Site.Menus.main` (and child
  trees, hiding parent panels whose children are all filtered out) across
  `navbar.html`, `navbar-group-items.html`, `shell/subnav.html`,
  `actions/quick-links.html`, `actions/root-order.html` and `index.llms.txt`.
  `navbar-entry-link.html` never marks an entry `.active` when its link
  resolved via `state == "role"`.
- `actions/site-commands.html` reads default-language base commands from
  unfiltered `hugo.Sites` so localized command overrides in a single-language
  role still inherit base `url`/`action`/`roles` before filtering.
- `content/version-targets.html` trims leading, trailing and consecutive
  `"---"` separators left after filtering, and `content/archive-directories.html`
  applies the same role filter.
- Unknown role names warn once and are ignored. An explicit malformed allowlist skips the entry.

### Outputs, caches and confinement {#outputs}

- **Search.** Whenever a site's role carries a directory prefix
  (`$index.rolePrefix != ""`), `search/index-resources.html` publishes its
  index and split body files under the site's directory (stripping `baseURL`'s
  subpath, e.g. `spec/zh/offline-search-index.spec.zh.json`). `assets/js/search.js`
  reads `data-td-search-page` from `.td-search` markup rather than baking
  `absLangURL` into `js/chunks/google-search.js`, keeping all root chunks
  role-invariant.
- **Robots and sitemaps.** `index: false` writes `noindex, nofollow` in
  `head.html` and emits an empty `<urlset>` in `layouts/sitemap.xml`. Hugo's
  root sitemap index already omits non-default roles.
- **Agent outputs.** `index.llms.txt` filters configured menus through
  `role-menus.html` and skips entries with state `missing` or `role`, keeping
  `llms.txt`, `llms-full.txt`, Markdown and NAVJSON strictly within their own
  role.
- **Template caches.** Every `partialCached` call whose output depends on site
  content or routing—including `backlinks-index.html`, `actions/root-order.html`,
  `shell/blog-index-pages.html`, `theme-color-pair.html`, `images-authored.html`,
  `language-targets.html`, `compare/targets.html`, `actions/context.html` and
  `shell/history-dialog.html`—keys on `.Site.Version.Name` and `.Site.Role.Name`.
- **Browsing history.** On a role with `listed: false` and a role prefix,
  `shell/history-dialog.html` scopes `data-td-history-scope` to
  `<basePath>/<role>/` (e.g. `/spec/`), so internal visits are stored under
  `td-history:/spec/`. For an unlisted default role at the root, the hidden
  and listed audiences use distinct `#unlisted` and `#listed` storage keys
  while validating URLs against the same physical base path.
- **Author files.** `static/` files and root-targeted global `assets` publish
  at the root in Hugo; protected assets belong in page bundles of that role.

### Duo View by version {#duo-versions}

The reader keeps one dialog, one runtime and `params.ui.compare` as its switch.
Its targets become the full transitive equivalence class of published
counterparts within the same role:

- `compare/targets.html` computes the fixed-point closure of `.Rotate "version"`
  and `.AllTranslations` from the current page within the current role,
  deduplicating by `(Version.Name, Language.Lang)`. A target must be a
  same-origin published HTML page of a Docs, Book or blog page (not paginated
  past page 1, not a draft), in a non-empty site whose language enables
  `compare`, other than the current page. Version home fallbacks and
  `params.versions` archives never qualify.
- Each target carries `version` and `latest` (`Version.Name == R.defaultVersion`)
  beside `url`, `code`, `direction` and `label`, ordered by Hugo's version
  order, then language order.

Opening and in-reader keys:

| Trigger | Behavior |
| --- | --- |
| `B`, `compare_translations` | Same version, another language: remembered `language`, else first available |
| `V`, `compare_versions` | Another version, same language: remembered `version`, else `R.defaultVersion` when reading an older version, else the version after the current one; if that version lacks the current language, its first available language |
| Entry button | `B` choice (with `ui_shortcut_compare` and `aria-keyshortcuts="B"`) when a same-version translation exists, else `V` choice (with `ui_shortcut_compare_versions` and `aria-keyshortcuts="V"`) |
| `B` / `V` while open | Pressing `Escape` or the active axis's key closes the reader; when only one axis differs from the left pane and the other axis is available, pressing the other axis's key retargets the right pane to that axis in place |

`B` is available when the current version has a translation; `V` when another
version has a counterpart. The palette lists each action only when available,
and the shortcut sheet dims unavailable rows.

Headings, menus and state:

- The left heading shows `中文 · v4.2`, omitting any dimension that does not
  vary across `[current, ...targets]`.
- The right heading renders the language menu before the version menu. A
  dimension with only one value across the available set renders as plain text,
  never a single-option dropdown: monolingual versioned manuals show only the
  version menu, and single-version bilingual sites match today's UI.
- Choosing a version preserves the currently selected right-pane language if
  that version has it, else the left pane's language, else that version's first
  language.
- Below 900 CSS pixels, variable menus render as compact triggers in the
  switcher row (`fa-language`, `fa-code-branch`), and pane switcher tabs match
  the pane headings.
- `localStorage['td-compare-reader']` stores `language`, `version` and `sync`
  independently (still reading legacy `target` entries), while
  `history.state.oinkCompareSession` stores the exact `{version, code}` pair
  and scroll bookmarks for reload and Back/Forward restoration.

### Keyboard map {#keyboard}

| Group | Today | Proposed |
| --- | --- | --- |
| Navigation | … `x` language, `r` section, `v` version, `h` history, `g` home | … `x` language, `c` role, `r` section, `h` history, `g` home |
| Actions | `/` and `f` search, `\` and `c` commands, … | `/` and `f` search, `\` commands, … |
| View | `b` Duo View, `z` Zen Mode, … | `b` Duo View (translation), `v` Duo View (version), `z` Zen Mode, … |

The sheet grows from twenty-nine to thirty rows (ten, nine and eleven). Row
`version` becomes `role`; row `duo-version` follows `duo`. `X`, `C` and `V` sit
side by side for language, role and version. Retired bindings (`v` as version
cycling, `c` as command-mode palette) join the contract's retired list.

### Accessibility, localization and print {#accessibility}

- The role menu reuses the version menu's disclosure semantics, focus
  management, Escape handling, forced-colors and RTL rules.
- Duo View's version and language menus are independent labelled listbox
  buttons in reading order `language` then `version`; invariant dimensions
  render as plain text.
- All 32 locale catalogs add `ui_role`, `ui_shortcut_role`,
  `ui_shortcut_compare_versions` and `ui_compare_version_select`.
- Print, Markdown, LLMS and RSS render no role or comparison controls.

## Publishing an internal role {#publishing}

Roles are not access control. Deployments choose one of two patterns:

**Publish behind authentication.** Build all roles and protect `/spec/` in the
server or CDN (e.g. nginx `location /spec/` or Cloudflare Access). With native publication paths, the
outputs for `spec`—HTML, bundles, aliases, `404.html`, empty
`sitemap.xml`, Markdown, LLMS, NAVJSON, Print and local search indexes—lie
under `/spec/`, while `localStorage` history stays under `td-history:/spec/`.

An authored URL or alias can override these paths. Check the built tree and
pass its Hugo log to `bin/check-version-links.py --public DIR --build-log LOG`;
any `[oink-role-path]` diagnostic blocks publication.

**Omit from the public build.** Layer the internal role and its full mount list
under `config/internal/hugo.yaml` so `hugo --environment internal` builds both
roles while the public configuration omits `spec`. Use a fresh destination for each deployment. For example, build into
`hugo --environment production --destination "$(mktemp -d)"` and
`hugo --environment internal --destination "$(mktemp -d)"`. Deploy only the
selected tree. Hugo can leave files from a previous build in a reused directory.

## Worked example {#example}

The companion site's `make spec` preview serves one Chinese working copy at
`/spec/` alongside bilingual Docs for v1.9, v1.7 and v1.6. See the
[working-language configuration](/docs/customize/roles/#working-language-preview).

The following configuration uses English as its project default and publishes
an unlisted Chinese space at `/spec/zh/`.

```yaml
defaultContentLanguage: en
defaultContentVersion: v4.2
defaultContentRole: public
languages: {en: {weight: 1}, zh: {weight: 2}}
versions: {v4.2: {weight: 1}, v4.1: {weight: 2}, v3.2: {weight: 3}}
roles: {public: {weight: 1}, spec: {weight: 2}}
module:
  mounts:
    - {source: content/latest, target: content, sites: {matrix: {roles: [public], languages: [en, zh], versions: [v4.2]}}}
    - {source: content/archive, target: content, sites: {matrix: {roles: [public], languages: [en, zh], versions: ['v3.*', v4.1]}}}
    - {source: spec, target: content, sites: {matrix: {roles: [spec], languages: [zh], versions: [v4.2]}}}
cascade:
  - target: {kind: '{page,section,taxonomy,term}', sites: {matrix: {roles: [spec], languages: ['**', '! zh'], versions: [v4.2]}}}
    build: {render: never, list: never}
  - target: {sites: {matrix: {roles: [spec], versions: ['**', '! v4.2']}}}
    build: {render: never, list: never}
params:
  offline_search: true
  ui:
    compare: true
    roles:
      spec: {label: 内部规格, icon: fa-solid fa-lock, listed: false, index: false}
```

The first `cascade` rule keeps `(spec, v4.2, en)`'s home and 404 page while
removing empty sections and taxonomies, so `/spec/` redirects cleanly to
`/spec/zh/` and no `v4.1` or `v3.2` directories are written under `/spec/`.
`index: false` automatically writes `noindex, nofollow` and empties `spec`'s
sitemaps. Links from `spec` to `/docs/install/` (whether translated or
English-only) resolve without warnings; public pages contain zero `/spec/`
references.

## Compatibility and migration {#compatibility}

- **Keys.** `V` opens version Duo View instead of cycling versions; `C` cycles
  roles instead of opening the command palette (`\` remains).
- **Duo View.** Sites with `params.ui.compare: true` and native versions gain
  version comparison automatically; single-version sites see no UI change.
- **Existing role sites.** Sites defining multiple listed roles gain the Space
  switcher; prefixed roles publish search indexes under their own directory.
- **Site-owned bundles.** Custom shells bundling `keyboard-nav.js` alone (such
  as `pgsty.com`) update their custom help copy if it listed `C` for commands.
- **Content.** No content or front matter migration is needed.

## Implementation plan {#implementation}

1. **Stage 1: Site and role model.** `content/site-index.html`,
   `content/role-index.html`, `content/role-config.html`, `content/role-home.html`;
   empty-site handling across `site-peers.html`, `version-identity.html`,
   `version-banner.html`, `language-targets.html`, `version-targets.html`,
   `archive-directories.html`, `seo-alternates.html`, `shell/search-enabled.html`,
   `search/index-resources.html`, `baseof.html`, `baseof.landing.html`,
   `head.html` and `layouts/sitemap.xml`; full `partialCached` role/version key
   audit across nine partials.
2. **Stage 2: Duo View by version.** Transitive closure in `compare/targets.html`;
   dynamic shortcut metadata in `compare/scripts.html` and `compare/entry.html`;
   `compare_versions` in `actions/context.html`, `actions/site-commands.html`
   and `assets/js/action-registry.js`; pure `assets/js/compare-targets.js` with
   unit tests; linked version/language menus, independent preferences and axis
   switching in `assets/js/document-compare.js` and `assets/js/compare-entry.js`;
   styles in `assets/css/td/document-compare.css`; `V` binding and `duo-version`
   row in `assets/js/keyboard-nav.js` and `shell/keyboard-help.html`; 32 locales.
3. **Stage 3: Role switching and space indicator.** `content/role-targets.html`,
   `navbar-role-selector.html`, `navbar.html` (desktop + drawer order fix),
   `shell/sidebar-panel.html`, `shell/subnav.html`, `shell/footer-line.html`;
   mobile compass and static single-space indicator in
   `assets/css/td/site-navbar.css`; `switch_role` action; `C` key and `role`
   shortcut row; `bin/check-params.py` and generated schemas.
4. **Stage 4: Cross-role links and scoped configuration.** Default-role
   ordered sparse fallback, adaptive explicit role resolution and cache-safe
   `leakedRole` warning in `content/site-destination.html` and
   `content/site-link.html`; `content/role-menus.html` across all six
   `.Site.Menus.main` consumers plus `navbar-entry-link.html` active-state guard;
   filter-before-resolve `roles` support in `actions/site-commands.html`,
   `actions/title-menu.html` and `content/version-targets.html`; schema updates.
5. **Stage 5: Output confinement, contracts and guides.** Subpath-safe site-dir
   search publishing in `search/index-resources.html`; static `assets/js/search.js`
   via `data-td-search-page`; unlisted role history scoping in
   `shell/history-dialog.html`; `index.llms.txt` cross-role exclusion;
   confinement and chunk-invariance checks in `bin/check-runtime-isolation.py`
   and `bin/check-version-links.py`; bilingual contracts and user guides.

## Verification {#verification}

| Checker | Coverage |
| --- | --- |
| `bin/check-version-links.py` | Asymmetric spaces fixture (`public` `en`/`zh` × 3 versions + `spec` `zh` × 1 version, with and without `cascade`, plus subpath `baseURL`). Empty-site exclusion, `/spec/` → `/spec/zh/` redirect with `cascade`, 5-step role targets, 4-step default-role fallback (including English-only fallback), adaptive `/spec/...` explicit links and leak warning, scoped menus/commands/links/archives, search files under `/spec/zh/`, `noindex` and empty `sitemap.xml`, `llms.txt` isolation, `history` scope, zero `/spec/` footprint across public files |
| `bin/check-compare.py` | Role/version fixtures and a six-language, six-edition chain with ten reachable targets; exact transitive target set, `compare_versions`, dynamic entry shortcut |
| `bin/check-runtime-isolation.py` | Static `google-search.js`, empty-site `search-enabled` gate, role-invariant chunk bytes |
| `bin/check-keyboard.py`, `bin/check-shell.py` | Thirty rows, `c`, `v`, `b` bindings, `role → language → version` order across navbar, drawers and footer |
| `bin/check-actions.py`, `bin/check-palette.py` | `switch_role`, `compare_versions`, command allowlist and localized command inheritance in single-language roles |
| `bin/check-params.py`, `bin/generate-config-schema.py --check` | `params.ui.roles`, `params.ui.role_menu` and `roles` filters: valid shapes, warnings, fallbacks, negative tests and schema parity |
| `bin/check-search.py`, `bin/check-backlinks.py` | Per-role index placement, no empty-site indexes, role-isolated backlinks cache |
| `bin/check-i18n.py`, `bin/check-goldens.py`, `tests/js/` | 32-locale parity, updated goldens, unit tests for `keyboard-nav`, `action-registry`, `compare-targets` and `document-compare` |
| Site suites | `make -C ../oink.pgsty.com check` and `browser` suites |

## Acceptance criteria {#acceptance}

1. The English-default example builds with zero warnings. Both with and without the
   `cascade`, `/spec/` redirects to `/spec/zh/`, and empty `spec` sites appear
   in no menu, `hreflang`, `llms.txt` or search index. In the Chinese-default
   companion preview, `/spec/` serves Chinese and old `/spec/zh/` bookmarks
   forward to the matching manuscript.
2. In `spec`, the version menu, version banner and `V` are absent; the language
   menu, `hreflang`, `X` and `B` offer no target; mobile and desktop headers
   show the Space compass.
3. Links from `spec` (`zh`) to both translated and English-only public pages
   resolve with `data-td-link="role"` and no warning; explicit `/spec/...` links
   from English or Chinese public pages resolve to `spec`'s Chinese pages and
   emit one leak warning per source and target URL; when `spec` is unlisted and unlinked,
   public HTML, `llms.txt`, `sitemap.xml`, JS chunks and `td-history:/` contain
   zero `/spec/` references.
4. Every file OINK generates for `spec` lies under `/spec/`, with
   `noindex, nofollow` on HTML and an empty `/spec/zh/sitemap.xml`.
5. `hugo` with the default environment produces no `spec` file and no reference
   to it.
6. In Duo View, `B` opens same-version translations, `V` opens cross-version
   counterparts, pressing the opposite key inside the reader switches axes in
   place, a ten-edge chain reaches its final counterpart, and single-axis sites
   display a single menu.
7. `C` cycles listed roles and returns from `spec` to the matching public page
   (across language/version if needed) or home; with one role and on the default
   space, the `role` shortcut row is dimmed.
8. Focused theme checkers, JS unit tests, and sibling site checks pass.

## Open decisions {#open-decisions}

None remain open. All original nine decisions (2026-12-03) and the v2 review
refinements (2026-12-04) are settled.

## Decision log {#decision-log}

- **2026-12-03 (owner):** Asked how Hugo roles work for a multilingual,
  versioned public manual (`en` default) paired with a Chinese-only, unversioned
  internal `spec` protected by prefix auth or omitted from public builds. Chose
  `C` to cycle roles (`\` opens commands) and `V` to open Duo View on another
  version inside one shared reader.
- **2026-12-03:** Initial draft written and nine open decisions settled by
  owner ("Space" / "空间" label, `listed: true` default, single
  `params.ui.compare` switch, `V` cross-language fallback, empty-site home
  redirect, leading role segment with leak warning, default role empty-site
  compatibility).
- **2026-12-04 (owner):** Reviewed architectural edge cases and approved the v2
  unified design for implementation: role-autonomous `defaultVersion` and
  `defaultLanguage`; 5-step role switching and 4-step default-role link fallback
  plus adaptive explicit-role resolution; `kind`-scoped `cascade` preserving
  `/spec/` redirect and automatic `layouts/sitemap.xml` emptying on
  `index: false`; `partialCached` role/version audit, static `google-search.js`,
  `llms.txt` role isolation, and `td-history:/<role>/` scoping for unlisted
  roles; `params.versions` defaulting to `listed: true` roles on single-version
  projects; transitive closure target discovery, independent axis preferences,
  and in-reader `B` ↔ `V` axis switching in Duo View.

---

Backlinks:

- [Proposals](/docs/design/proposals/)
