Coming from GitHub #11123, you can find detailed descriptions and examples there.
Long story short:
After @jmooring pointed out that the strange behavior is not Hugo’s bug. I found that the proper way to use the <figure>
tag with an image would be something like this (ref):
<figure>
<a href="https://creativecommons.org/licenses/by-nc/4.0/">
<img src="https://licensebuttons.net/l/by-nc/4.0/88x31.png" alt="CC BY-NC 4.0 License">
</a>
</figure>
The order should be <figure>
, <a>
, <img>
.
Of course, I can achieve this by writing a custom shortcode, but I would very much like to keep my post markdown in their original format, for instance:
[![CC BY-NC 4.0 License](https://licensebuttons.net/l/by-nc/4.0/88x31.png)](https://creativecommons.org/licenses/by-nc/4.0/)
Ideally, this should have been achieved by tweaking the render-image.html
hook, but maybe I’m too tired to come up with the right way. Any thoughts?
Here's what I have so far
For now, I don’t have render-link.html
and have a render-image.html
like this:
<figure>
<img src="{{ .Destination }}" alt="{{ .Text }}" />
</figure>
Which yields:
<p>
<a href="https://creativecommons.org/licenses/by-nc/4.0/">
<figure>
<img
src="https://licensebuttons.net/l/by-nc/4.0/88x31.png"
alt="CC BY-NC 4.0 License"
/>
</figure>
</a>
</p>
which results in a wrong order: <a>
, <figure>
, <img>
.
What’s worse is that the browser translates this to:
<p>
<a href="https://creativecommons.org/licenses/by-nc/4.0/">
</a>
</p>
<figure>
<a href="https://creativecommons.org/licenses/by-nc/4.0/">
<img src="https://licensebuttons.net/l/by-nc/4.0/88x31.png" alt="CC BY-NC 4.0 License">
</a>
</figure>
<p></p>
I’m clueless.