AMP image template

Simple question: I have 3 templates:

  1. _default/baseof.html
  2. _default/baseof.amp.html
  3. partials/image.html

How can I send a variable to the “partials/image.html” from the first 2 to be possible to have:

{{ if eq "site" "namp" }}
 <img src="...">
{{ else if eq "site" "amp" }}
<amp-image>
 <img src="...">
</amp-image>
{{ end }}

without having 2 templates for image?

You can pass a dict to a partial: https://gohugo.io/functions/dict/#example-using-dict-to-pass-multiple-values-to-a-partial

1 Like