Add ./hugo.txtar
Author: bepCreated Oct 5, 2022Updated Sep 28, 2026
LabelsProposal
This is related to #9726 but smaller in scope, which makes it a good starting point.
It would be cool and useful, especially for smaller setups and template projects/modules to have a compact way to add a file structure to a project. I really like working with txtar files in integration testing, and I suspect it would work great in this setting, too, e.g.:
-- hugo.toml --
baseURL = "https://example.org"
-- content/posts/_index.md --
CONTENT HERESome notes:
- I think we can make a simple read-only
aferofilesystem that makes it fit nicely into the existing overlay filesystem with mount support and all. - The precedence for each file inside an archive would work the same as real files on disk; e.g. files in the project with the same name would win over the same filename in a theme/module.
- I don't want to make any guarantee about ordering on duplicates within e.g. project, mostly to make the server rebuilds on changes as simple as possible. This is similar to how
_content.gotmplworks. Thesetxtarfiles are typically relatively small so I think it would make sense to, when in watch mode, keep a map of filenames to a content hash, and calculate a change set whenever thetxtarfiles changes and pass the changed (or added, removed) files in as events to the build. - For server rebuilds on changes to
hugo.txtar:- We need to detect config changes and do a full rebuild like we do with other config changes.
- We also need to try to preserve a level of fine grained rebuilds (maybe take some inspiration from how
_content.gotmplworks).
Source: gohugoio/hugo