Add roles and versions as new dimensions (in addition to language) #13679
Conversation
864cfcd to
779649e
Compare
e914f3f to
6f88a60
Compare
01f9c33 to
cf40195
Compare
958d82b to
f131d38
Compare
9a2ad51 to
35d3765
Compare
3228817 to
99dda69
Compare
bcfcc8e to
9258481
Compare
e67330a to
c2bf0d5
Compare
c2bf0d5 to
4c1b2f4
Compare
|
@bep Just curious, can you give an example of when you'd use roles or versions? It isn't clear to me from your example. |
|
@willfaught this is a draft ... but
|
|
@bep Why would you publish the same text under multiple versions? To save you from duplicating the text if the text didn't change between versions? How would roles work for privileged content/pages in a static site that's just serving files from a directory? |
You don't have to do that. I have written a fair amount about how this is intended to work, which will improve and make the language support behave the same. That is, you can e.g. define that a piece of content should either be rendered/duplicated to a set of languages or act as a fallback for a set of languages. As to roles, you would obviously need authentication and authorisation outside of Hugo, but the authorisation part will be simple/directory based. |
|
This looks promising for solving my usecase where I've made my own implementation for versioning arbitrary sections/paths. If 'version' could be assigned to content via directories, and "populate" the parent dir based on selected version, this would nearly solve my usecase. I.e: If the above would let me have The only missing thing then would be the front matter of _index.md, which in my custom setup I sadly have to handle with outside tooling and search'n'replace (tried using mounts and copy in a shared/_index.md mixed with cascading params with targets, but due to a bug with this approach and the param shortcode it failed). If, in the above example, front matter was merged - letting the versions _index.md take precedence, this would solve my usecase 100% (Would be even doper if you could have different |
@repsejnworb I'm not sure I understand your setup, but with this PR you can set versions via paths via front matter (directly or via cascade (either in config or in a branch node's front matter)), see #13776 for slightly more info. This was the main reason why taking this PR the last 10% became a little bit of a struggle. |
There was a problem hiding this comment.
Pull Request Overview
This PR adds roles and versions as new dimensions to Hugo's build matrix, expanding beyond the existing language dimension. This enables building sites with multiple versions (e.g., v1.0.0, v2.0.0) and roles (e.g., guest, member), allowing content to be selectively rendered based on these dimensions.
Key Changes:
- Introduces a 3-dimensional sites matrix structure (language, version, role) replacing the previous language-only model
- Adds new configuration options for versions and roles with associated metadata
- Updates content filtering and rendering logic to support multi-dimensional site builds
Reviewed Changes
Copilot reviewed 136 out of 209 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| hugolib/sitesmatrix/dimensions.go | Defines core types for 3D vector operations and dimension constants |
| hugolib/sitesmatrix/dimensions_test.go | Test coverage for vector comparison and distance operations |
| hugolib/roles/roles.go | Implements role configuration and management system |
| hugolib/segments/segments.go | Updates segment filtering to support multi-dimensional sites |
| hugolib/site.go | Refactors Site struct to support version and role dimensions |
| hugolib/page__meta.go | Splits page metadata into source and per-dimension components |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
See the main issue gohugoio#13776 for details. Fixes gohugoio#519 Fixes gohugoio#13680 Fixes gohugoio#13663 Fixes gohugoio#13776 Fixes gohugoio#13855 Fixes gohugoio#13648 Fixes gohugoio#13996 Fixes gohugoio#14001 Fixes gohugoio#14031 Fixes gohugoio#13818 Fixes gohugoio#13196
See #13776.