Can the slug be used as the base name for an output format?

I have this config:

[permalinks]
  post  = "/:year/:month/:slug/"

[outputFormats.text]
  mediatype = "text/plain"
  baseName = "copy"
  isPlainText = true

[outputs]
  page = ["html", "text"]

So for a post with the URL /2023/08/hello-there, it creates both 2023/08/hello-there/index.html and 2023/08/hello-there/copy.text. But Iā€™m wondering if there is some way to configure the text output format to use the slug for the file name instead of the directory, so that it would instead create 2023/08/hello-there.text ā€” in other words, on the same level as the hello-there (slug) directory.

So far in my fiddling it appears everything just goes into the directory (yay page bundles!). So before I went too far down the path of trying different things I thought Iā€™d ask here whether this sort of pattern is even possible in Hugo today ā€” and if so, how?

Enable uglyURLs site-wide, then disable for the html output format.

uglyURLs = true

[permalinks]
post = "/:year/:month/:slug/"

[outputFormats.html]
noUgly = true

[outputFormats.text]
mediatype = "text/plain"
baseName = "copy"
isPlainText = true

[outputs]
page = ["html", "text"]

published site

public/
ā”œā”€ā”€ 2021/
ā”‚   ā””ā”€ā”€ 01/
ā”‚       ā”œā”€ā”€ post-1/
ā”‚       ā”‚   ā””ā”€ā”€ index.html
ā”‚       ā””ā”€ā”€ post-1.txt
ā”œā”€ā”€ post/
ā”‚   ā””ā”€ā”€ index.html
ā”œā”€ā”€ favicon.ico
ā””ā”€ā”€ index.html
1 Like

Oh, nice, yes, that works perfectly, visible here. Thanks!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.