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.
To illustrate (and test) the core functionality, I added some more output types to my site bepsays.com. 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
http://bepsays.com/en/ and see the “link rels” in the source header to the different represenations.
The home page http://bepsays.com/ 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.
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:
index.json
index.json.tmpl
Another example:
baseof.amp
baseof.amp.tmpl
baseof.amp.html (Can this lookup go away? Should we check for baseof.json.html or baseof.ical.html?)
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).
The forum software has a lower limit of 5 chars for posts, so I have to append “…” to my replies
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.
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.