![office with a view of Thames river](/assets/post-img/office.jpg){:class="myClass"}
This gets translated into:
<img src="/assets/post-img/office.jpg" alt="office with a view of Thames river" class="myClass">
But in Hugo the class gets ignored. How do I achieve that? That would really amazing it if I didn’t have to turn all img markdowns to HTML tags just so to inject a custom class.
Please read the link I posted above carefully also search the forum for Markdown Render Hooks, there are examples around.
Markdown Render Hooks are templates that go under a specific path, therefore simply by entering a markdown syntax image in a content file you can output whatever HTML and class
if it’s something you need often (for exemple a full width image in a blog article) you can’t create a shortcode for that? What is the difference between the solutions?
But Markdown Render Hooks are more intuitive, as you do not need to use Hugo specific Shortcode syntax and therefore you can use pure Markdown that is portable in whatever content editor and coupled with Page Bundles one can get image previews directly in the editor.
I only rarely use Hugo Shortcodes these days, when I have a specific need.
Most of my projects have been converted to use Markdown Render Hooks as these make content authoring more pleasant and intuitive.
execute of template failed: template: _default/_markup/render-image.html:2:68: executing "_default/_markup/render-image.html" at <.Class>: can't evaluate field Class in type goldmark.linkContext
It seems the linkContext only accepts specific predefined hooks, as shown here
I suppose I need to pass the Page context and set that variable in config?