Spaces (roles)
Hugo roles add a third dimension beside languages and versions. In OINK,
each role acts as an audience space — for example, a public documentation
site alongside an internal /spec/ manual or an /enterprise/ edition built
from the same repository.
Hugo builds static files. listed: false hides the space from public space
menus. Search indexes are scoped by role. index: false empties the role’s
sitemap and asks crawlers to skip its pages. Enforce authentication for
/<role>/* at the reverse proxy or CDN.
Asymmetric spaces in one project
Different spaces rarely share the exact same languages and versions. A public
manual might publish English and Chinese across v4.2 and v4.1, while an
internal spec space is written in Chinese only on v4.2. The default role
keeps its configured sites, including data-driven Landing pages. For other
roles, OINK uses the published content to determine the available languages
and versions, their defaults, and the entry page.
On /spec/zh/:
- No language switcher, version switcher, or archived-version banner renders,
because
spechas one language and one version. - Visiting
/spec/redirects automatically to/spec/zh/. - Public pages show no role switcher (only one
listed: truespace exists), while/spec/zh/shows the Space compass. Its menu switches back to Docs (Cor the Command Paletteswitch_roleaction).
Role metadata (params.ui.roles)
Configure per-space presentation under params.ui.roles.<role> (or per language
under languages.<lang>.params.ui.roles.<role>):
| Key | Type | Default | Description |
|---|---|---|---|
label |
string | role name | Space name in the menu and in the compass’s accessible label |
icon |
string | "" |
Optional Font Awesome class pair, such as fa-solid fa-lock |
listed |
boolean | true |
Include this space in public role switchers and switch_role choices |
index |
boolean | true |
When false, emits <meta name="robots" content="noindex, nofollow"> and an empty <urlset> in sitemap.xml |
params.ui.role_menu overrides the localized Space menu title.
Scoped menus, commands, links, and versions
Shared configuration blocks accept an optional roles allowlist evaluated
before URL resolution:
- Main menu (
menus.main): setparams.roles: [spec]on top-level or child menu items. - Command Palette (
params.ui.command_palette.commands): setroles: [spec]to expose internal shortcuts only insidespec. - Page context links (
params.ui.page_context_menu.links): setroles: [public]orroles: [spec]. - External version archives (
params.versions): entries withoutrolesappear automatically on multi-version spaces (orlisted: truespaces in single-version builds); setrolesexplicitly to override, and surrounding"---"dividers are trimmed automatically.
Cross-role links and leak checks
- Default-role fallback: inside a non-default space such as
spec, an ordinary root-relative link like[Install](/docs/install/)that does not exist inspecresolves automatically to the default space (public), preferring the current version and language before falling back to the default space’s default version and language. - Explicit space path:
[RFC 001](/spec/rfc/001/)resolves insidespecusingspec’s own versions and languages. - Unlisted leak warning: if a
listed: truespace links to alisted: falsespace (in Markdown or an unscoped menu/command/link), the build logs a warning naming the source file or configuration key so internal URLs do not leak by accident.
Confinement of generated files and history
Every prefixed role publishes its local search index (offline-search-index.*.json),
llms.txt, navigation.json, and sitemap.xml inside its own /<role>/
directory. Check authored URLs and aliases before deploying. A prefixed
unlisted space stores its browsing history under its directory key, such as
td-history:/manual/spec/. If the unlisted default space occupies the site
root, it and the listed spaces start separate histories. To protect a default
space with a directory-based gateway rule, set defaultContentRoleInSubdir: true.
Build environments and the Design example
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.
Hugo lets authors override publication paths. In a prefixed role, use a
relative front-matter url such as guides/install/. Check the log from the
same build before deploying a mixed tree:
An [oink-role-path] diagnostic identifies the source and misplaced output or
alias. Correct it and rebuild into a clean directory. A gateway rule for the
role directory covers files physically under that path. Project-owned static
files and custom templates also need to publish protected material there.
Chinese working space example
Run make spec in the companion site. Read the Chinese working copy at
/spec/ or open its architecture contract at /spec/architecture/.
The preview sets defaultContentLanguage: zh and defaultContentVersion: v1.9.
Hugo omits both default prefixes. Chinese Docs therefore lives at /docs/
and English Docs at /en/docs/ in this build.
For a new site, declare the role and add this mount to module.mounts.
An unqualified manuscript inherits the project’s default language and version.
spec/architecture.md therefore publishes at /spec/architecture/.
The same configuration works with a role named rfc or adr. A role with one
published slot has no language or version choices. Hugo uses the project defaults
to construct URLs. In an English-default project, a Chinese working copy lives
under /<role>/zh/. A language suffix such as .en.md can select another slot
even when the mount specifies Chinese. Use a file filter or disable the other
slots with cascade to keep one working copy.
The companion site selects the *.zh.md manuscripts in content/docs/design/
and disables the other slots.
Its compass opens a menu back to Docs. Search and print cover the working copy.
Earlier /spec/zh/ and Design bookmarks forward to each page with its query
and fragment. Old Markdown addresses link to the current source. Existing
print URLs and feed subscriptions still work. Unmounted English and historical
SPEC pages return 404.
Docs offers the v1.9 development manual and the archived v1.8 manual in both
languages, the two versions the site declares in hugo.yml. Open
/en/docs/start/from-scratch/ and switch versions to read each installation
guide. Press V to compare them side by side. Run make spec-check and
make spec-browser to verify this configuration.