ERROR 2022/12/10 12:03:03 Rebuild failed: "C:\steppa\site\content\test\index.md:1:1": "C:\steppa\site\themes\hugo-theme\layouts\_default\_markup\render-image.html:2:21": execute of template failed at <$img.Resize>: nil pointer evaluating resource.Resource.Resize'
It was caused by a back slash in an image link ![image](/image/image.jpg) which should have been ![image](image/image.jpg) in the page bundle. How can this error be made more clearer? It took me a few hours to notice the issue causing it.
The first part of my image render hook look like this
I don’t know, I think the error message is already pretty good. The error message is pointing you to the line and column where the error happens. If you edit e.g. Visual Code, clicking on the error will take you to that line.
But i guess the error message “nil pointer …” (which I think comes from the Go std library) is a little foreign to many and could be elaborated on.
I need this part in, thus I will put your solution on hold because integrating that part throws errors and stops the build.
My markdown images are in this format ![image here](img/image.jpg "image title") with image here as the $alt and image title as the $caption.
But your answer works with the caption part excluded.
That will ease everything. I realized today the preceding \ points to the base URL and not the file path in page bundles.
$.Title and $.PlainText solves it. That global context is a lifesaver. But that means everything else needs to be wrapped in the $, for example, the .Ordinal bit which I found in the release notes.
A nil pointer exception is in this context is perhaps related to the image not being found. A typo in its name or something like that. So check for the existence of the Resource before using it.
I have seen that error a few times, but the language is not beginner-friendly. Search the forum for similar questions and there are several. Making it more clearer is better.