Hugo

Defining a second output format for the same media type

Hi,

I wanted to define two output formats for the same media type in parallel and let the user choose in the site.Output node which one to use.

This is an example to choose between “Atom” and “AtomExt” while “Atom” will result in a name file “atom.xml” and “AtomExt” in “feed.atom” (to comply with web standards about this file extension name and to make it easier for web servers to send the correct Content-Type HTTP response header):

[outputs]
  home = [ "HTML", "JSON", "RSS", "AtomExt" ]
  section = [ "HTML", "RSS", "AtomExt" ]
  taxonomy = [ "HTML", "RSS", "AtomExt" ]
  taxonomyTerm = [ "HTML", "RSS", "AtomExt" ]

[mediaTypes."application/atom+xml"]
  suffixes = ["atom", "xml"]

[outputFormats.Atom]
  name = "Atom"
  mediaType = "application/atom+xml"
  baseName = "atom"
  isPlainText = false
  rel = "alternate"
  isHTML = false
  noUgly = true
  permalinkable = false

[outputFormats.AtomExt]
  name = "Atom"
  mediaType = "application/atom+xml"
  baseName = "feed"
  isPlainText = false
  rel = "alternate"
  isHTML = false
  noUgly = true
  permalinkable = false

However, this does not seem to work. What I can see is that even though both output types are using different names for the node itself, the display name (which I want to be the same) seems to have priority so that this ends up in an unpredicted mess of both configurations.

Can someone explain why this wouldn’t work or whether this is some kind of a bug in Hugo and SHOULD work?

Thanks,
Julian

1 Like

Are you aware that the Name of your second format is identical to the first one? The attribute.

I agree that the documentation may be a little ambigous when it is talking about “name”, and I don’t remember the details to tell you exactly what happens in your case, but I have a pretty good guess: If you drop the “name” setting I suspect it will work fine.

1 Like

Thank you for replying to this!

Removing the name attribute will not be sufficient nor will it give me the flexibility I am looking for.

When removing the name attribute, I still need to adjust the order of the suffixes and make that suffix I want the primary one.

I also want to use the name attribute as a display name being used in the feed file because it can be visible to end users. They shall not see the technical name of the node itself.

So question no. 1:
How does the concept about having multiple suffixes work? It seems only the first in line will be considered.

Question no. 2:
Can I somehow explicitly refer to a specific suffix from the outputFormat definition?

Question no. 3:
Is there a way the name attribute will not be handled as the primary identifier? My understanding is that it would be better to use the node as the technical identifier, not the attribute that is actually a level below.

I guess conclusion is now that concurrent output formats cannot be defined in parallel and always need to be re-defined be the user itself, meaning there is no way to make it easier for users by just choosing a different output format name in the [site.outputs] map.

:frowning: