I’m creating styleguide.md file and trying to use Hugo’s image short code from this link but it’s not clear for me from the example on the same page how to use it?
When I add this code in styleguide.md file:
{{< imgproc sunset Resize “300x” />}}
I get an error. Should I define image title and src e.g. “sunset” somewhere?
That’s because $original is not an image resource. Check the file name and everything else. The problem here is not with Hugo.
You could add something like {{warnf "%#v" (.Get 0)}}
at the beginning of your shortcode to see what Get 0 really returns.
Of course. I have no idea what you’re passing in as parameters. And I didn’t even pretend that the error would go away simply by printing out a warning message. I just tried to help you with figuring out what might go wrong.
But I’ll stop here. Please go and read the documentation. Try to understand what Resources are (there’s a whole chapter on those) and how you pass parameters to a shortcode (hint: You can’t pass something like Resize without including it in quotes, because the bare word is a command).
Also, if you ask for help, try at least to be consistent in your problem description. In your first post, you used {{<imgproc sunset Resize “300x”>}} (which can’t work because you do not quote your parameters). In your second post, your shortcode has another name and you’re quoting the image (which does not help because Hugo needs a resource not a URL).
I’m sorry because of the inconsistency. In the meanwhile I was trying to resolve the issue and changed the imgproc into img, but foresaw to change it after the pasting and it was my bad I haven’t checked it once again before replying.
I’m new to Hugo and although I was going through it’s documentation (and watched YT videos about it) I’m having difficulties understanding it, especially it’s examples and explanations.