New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support shortcode per output format #3220

Closed
bep opened this Issue Mar 23, 2017 · 1 comment

Comments

Projects
2 participants
@bep
Member

bep commented Mar 23, 2017

#2828 handles the technical grits of handling multiple output formats in Hugo.

But it deliberately ignores a problem that is especially relevant in the AMP world: Special amp-img etc. tags.

So, while I believe we must accept that, in short term, Blackfriday and friends are good old HTML renderers, Hugo will have to do better in this area.

And then there are two options:

  1. We do replacements on the raw HTML output.
  2. We do something clever with shortcodes.

The first one may be both fast and possible, but it would be hard to maintain for other than simple AMP image replacements.

So, it is shortcodes.

Of course, in Hugo we render the content once and reuses that for the different output formats. We want to keep on doing that because it is ... fast ...

But, luckily, the way shortcodes are architected, it is possible to do a reprocessing of the shortcodes only, and only a subset of them if needed.

So, my suggestion is that we come up with a way to have multiple versions of the same shortcode. The first that comes to mind:

/shortcodes
image.html
image.amp.html

The idea that we do re-expansion/evaluation of the shortcodes only for the pages and the shortcodes that have alternative representations, which should not hurt the performance in the normal use cases.

The naming convention above isn't really that important, but as this is by no means a trivial change, we REALLY need to think that this is a GREAT IDEA.

/cc @spf13

@bep bep added the Proposal label Mar 23, 2017

@bep bep added this to TODO in Custom Output Formats Mar 24, 2017

@bep bep added this to the v0.21 milestone Apr 10, 2017

@bep bep added Enhancement and removed Proposal labels Apr 21, 2017

@bep bep changed the title from proposal: Shortcode per output format to Shortcode per output format Apr 21, 2017

@bep bep changed the title from Shortcode per output format to Support shortcode per output format Apr 21, 2017

@bep bep removed this from TODO in Custom Output Formats Apr 26, 2017

@InderdeepBajwa

This comment has been minimized.

Show comment
Hide comment
@InderdeepBajwa

InderdeepBajwa May 8, 2017

What's the progress on this? I'm eager to get amp-img implemented on Hugo!

InderdeepBajwa commented May 8, 2017

What's the progress on this? I'm eager to get amp-img implemented on Hugo!

@gohugoio gohugoio locked and limited conversation to collaborators May 8, 2017

@bep bep closed this May 13, 2017

dmerejkowsky pushed a commit to dmerejkowsky/hugo that referenced this issue Dec 3, 2017

hugolib: Handle shortcode per output format
This commit allows shortcode per output format, a typical use case would be the special AMP media tags.

Note that this will only re-render the "overridden" shortcodes and only  in pages where these are used, so performance in the normal case should not suffer.

Closes gohugoio#3220
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.