Hi everybody.
I am trying to set up per-page output format for a taxonomy term page according to the documentation I found here: Custom output formats | Hugo.
I set up a simple example site over at GitHub.
It provides
- two categories “foo” and “bar”
- alongside two posts “Post #1” (category: “foo”) and “Post #2” (category: “bar”).
For category “foo”, only html
output should be applied.
For category “bar”, the outputs html
and json
should be applied.
The latter was configured by using the following YAML front matter at content/categories/bar/_index.md
:
outputs:
- html
- json
For demonstration purposes, the index page of the example site uses static links to the HTML and JSON representations of both categories.
I expected Hugo to render
- “Page not found” for the link of
/categories/foo/index.json
, and - a JSON representation for the link of
/categories/bar/index.json
.
But suddenly, this stopped working and Hugo renders a “Page not found” for the link of /categories/bar/index.json
, too.
It looks like a workaround is necessary by:
- configuring site-level
outputs
configuration for the termKind
- set the list of allowed outputs of the term “bar” to
['html', 'json']
. - set the list of allowed outputs of the term “foo” to
['html']
.
The adjusted configuration can be found in branch “workaround-configuration” of the same GitHub project.
I once got that up and running, without the workaround, with help of topics I found in this forum.
Am I getting this right?
Do I missed something since the latest Hugo updates?
My Hugo environment looks the following:
22:07 $ hugo env
hugo v0.124.0-629f84e8edfb0b1b743c3942cd039da1d99812b0+extended darwin/amd64 BuildDate=2024-03-16T15:44:32Z VendorInfo=brew
GOOS="darwin"
GOARCH="amd64"
GOVERSION="go1.22.1"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.3.2"
Thanks in advance for your help and feedback,
Tommy