Custom Output Formats: Feedback Wanted!

The development of the Custom Output Feature is mostly done (there are still lots of smaller TODOs flying around), but it would be nice to get some feedback on this now. It is easier to change it now before people start to use it.

For background, see

To illustrate (and test) the core functionality, I added some more output types to my site This commit shows all the changes:

Don’t mock my AMP design skill!

The above commits have the following new items:

  • Output format definitions in both site and page config
  • A crude AMP version + JSON for the English home page.
  • Enhanced template handling, including base handling per output format.
  • Use of the AlternativeOutputFormats to create a list of “link rel” to alternative representations. Note that there is also an OutputFormats list that lists all, and a Get method to get a specific format by name.

To see it in “action”, go to

  • and see the “link rels” in the source header to the different represenations.
  • The home page has no content page, and gets its output definitions from the site config (and hence no JSON output).

I’m pretty happy to see how compact the change set to my site above is, considering the amount of sweat I poured into the Hugo source code to get there …

But even if this may be clear and correct to me, it may not be so to you. So comments and corrections are appreciated.

1 Like

Looks great, bep. :heart:

Would this be a good time to support template files with an optional .tmpl extension? Opening layouts/index.json (which used to be layouts/json/single.html) makes my syntax-highlighting editor go crazy. Example lookup order:

  1. index.json
  2. index.json.tmpl

Another example:

  1. baseof.amp
  2. baseof.amp.tmpl
  3. baseof.amp.html (Can this lookup go away? Should we check for baseof.json.html or baseof.ical.html?)

What would be the best solution to get images inside a markdown file to have the correct amp markup (amp-img)?

Probably not a good time … It is pretty much changes as is, and I’m not spending time reworking that logic for that, that will have to wait. And I’m not sure how tmpl would be any better for syntax highlighting.

@Groovy shortcodes would be the answer, but I guess there are some issues with URLs in content files for AMP and regular HTML, but I’m not solving all of those issues in this PR.

Not sure what you mean. Baseof.json.html does not make sense (unless you have defined html as your JSON suffix, which sounds insane). But, anyhow, we’re not changing this for this release (we kind of had this discussion already).

Just to be clear on the tmpl ext, I mean in this release, not this PR.

OK, I suggest you describe it in a GitHub issue, but it will have sith tight until the next release.

@Groovy Re. AMP media types.

I just created this suggestion:

Please chime in with your thoughts.

Do you have a “post” such as in AMP format?


Kort och koncist svar som vanligt :wink:

The forum software has a lower limit of 5 chars for posts, so I have to append “…” to my replies :slight_smile:

But there are no “magic” and special about “post” pages in this area – we have some challenges re. content vs. AMP tags, but that is described in the link above.

Haha, I heard it was dubbed the bep-min-char variable in the forum settings :blush:

You’re right, posts will often be more ‘simple’ than other pages, especially a home page.

Great suggestion, it would make it very easy to handle markdown with mixed images + text (and also simplify templates for amp).

I have merged the bulk of this feature into master now. It was a little more work than I had expected; it felt like every little change required a rewrite of that part of Hugo (we had plenty of URL and path handling floating around with hard-coded extensions etc.). But it’s all spring-cleaned now!

I still have work left to be done, but it should be usable now – and I would love for you to take it for a spin and report back if I, God forbid, have introduced any unforeseen issues. :slight_smile:



For a total progress report.


No issues with the custom output so far :slightly_smiling:
Is the output format type accessible from a template?

@Groovy care to share your code for amp-img? Would be nice to see your implementation

Sorry for the late reply. I can do it when I get back home later today.

No worries mate, got it covered!