The easiest thing to do: use an extension that doesn’t map to a content file (e.g., txt
). Can you do that instead? This would allow you to use your existing code.
Otherwise, you’ll need to use either of these examples:
https://github.com/gohugoio/hugo/issues/12274#issuecomment-2007144611
The second example is better in that you don’t have to specify the path twice.