The way I am organizing my content is that I upload images into the posts directory (e.g. content/posts/posttitle/ and there are image.jpg and index.md).
The filename is listet as an image:-ressource in the index.md frontmatter and is used by an imgproc-shortcode to generate different sizes to be displayed be single.html and a larger version as a tagget to be linked to. That is all fine and works exactly as I want it to.
What I would like to do, is create three different image sizes, the large sized one to be linked to, a medium sized one to be displayed by single.html, and a small sized one to be displayed by list.html.
Since the shortcode gets used by both single.html and list.html, the figure-tag always contains the same filenames (in this case $medium.RelPermalink and $large.RelPermalink).
I guess what I would like to have, is a way to make the shortcode find out if it is called from single.html or from list.html and use $small.RelPermalink instead if it is from list.html.
Is that even possible? Or would there be a different solution?
So, Hugo tries to avoid doing extra work, so the .Content (and shortcodes) currently gets re-rendered if there are language or output format specific variants of any shortcode (or rendering hook) in that file.
So, I think your best option here would be to create 2 output formats for HTML (one for the sections/list, and one for the … others). And then create 2 imgproc shortcodes on the form ìmgproc.outputformatname1.html ìmgproc.outputformatname2.html …
That sounds promising and I would like to try it, but I don’t understand how that works or what I would have to change in my files. Could you please elaborate - if you don’t mind?
So I’ve created
hugo/layouts/shortcodes/imgproc.list.html
hugo/layouts/shortcodes/imgproc.single.html
The site still renders without any changes to any other files, but nothing has changed, the images are still medium sized in the list-view.
Maybe I need to add that I’ve change the default list.html from rendering .Summary to rendering .Content.
Do I have to define the lookup order you’ve mentioned?
Edit: Lookup Order doesn’t mention any shortcode-dirs when listing the lookup order.
I renamed the shortcode-file containing the code to link to the smallest imagesize imgproc.list.html to imgproc.index.html which resulted in that shortcode being preferred when rendering the main index-page /index.html.
But then also all /posts/posttitle/index.html also got rendered using the shortcode imgproc.index.html and imgproc.single.html didn’t get used at all.
Apparently the lookup order is not based on the layout file being used, but the target filename.
In the case of the main /index.html the layout file is layouts/_default/index.html, but all blogposts that get rendered by layouts/_default/single.html get written as index.html, too.