Hi all,
In order to improve the permormance of my site I would like help and have your opinion on the integration of images.
I want to modify Hugo’s Layouts in order to
be able to use the picture tag instead of the img tag.
Here is an example of code:
If you want to set image in front matter, then you reference those images in the templates where you want to show the image, for instance in the single.html template where a “feathered image” would appear.
Alternatively, you can use a shortcode to render the images inline. Search the docs for the “figure shortcode”, it will show you that method.
I would just use a single entry for the image file in the front matter since they are all the same except the extension then make a shortcode with this:
Hugo cannot convert to the other formats -if that is your question-. You need to provide all formats because otherwise there will be an error that will prevent your project from building.
Thank you
Benmarte’s solution is easy to set up. I was thinking of something more dynamic.
A condition so that we don’t have to worry about the number of images to provide.
{{< picture src="images/portfolio/your-business" title="Exemple de page statique responsive" >}}
Indeed, this requires providing the 3 image formats well, it is not necessarily easy to manage.
I don’t know if there is a method to convert the images dynamically