I’ve been trying to get image processing to work in Hugo for the last three days or so.
Now I’m asking for some tailwind of the community, maybe someone has a simple answer for me.
All topics and related code, which I was able find deals either with super sophisticated shortcodes, where I can’t see any start (or make sense out of it), or it is just a part of incomplete code, where the writer assumes, that I know all the rest of it. I don’t.
My question:
What is the current status of image processing in Hugo? Or phrased differently:
What is the most simple form of some image code, which will output and process/compress a simple image?
I have tried:
- to put an image in the same folder like the _index.md > content/posts/my-post + image.jpg
- to put an image in the root-assets folder like assets/images/image.jpg
- to put an image in the static folder at the root level.
I have followed the docs to include and process my images with the following code:
Get the image as a resource
{{ $image := .Resources.GetMatch “/images/November-Sunrise.jpg” }}
Code to output the image
{{ $image.RelPermalink }}" width=“{{ $image.Width }}” height="{{ $image.Height }}
This is the code for the src attribute of the image (taken straight from the docs).
In all three cases I get an unrendered output/code as a result.
As you can see in the first screenshot in the bottom right corner, no images are being processed (Or the one I’ve tried to include).
I also found this post Image render hook does not work with page resources any more · Issue #6851 · gohugoio/hugo · GitHub where this feature is being discussed.
I must be doing something wrong? Thanks in advance for some ideas on how to solve this simple one.