Strange behavior, (maybe ?) not a bug but could interest you

Something funny happened, an issue solved now but still puzzling as I can still reproduce the behavior. Maybe that feedback could be of interest to developers. I am not sure if you guys would consider this a bug or just a counter-intuitive behavior :thinking:

I had a shortcode with this:

<figure class=“aside”>
{{ .Inner | markdownify }}
</figure>

and it used to work. then I needed a render-image.html specific to the homepage so I added “type: home” added to its frontmatter and made it, fine, but too fine: it created that error on a template not used at all on the homepage but in other pages:

kiddygirland.md:162:1": failed to render shortcode “ff”: failed to process shortcode: “ff.html:2:12”: execute of template failed at : error calling markdownify: “/home/drm/WEBSITE/content/_index.md:1:1”: “/home/drm/WEBSITE/themes/hugo-book/layouts/home/_markup/render-image.html:17:13”: execute of template failed at <$img.Width>: error calling Width: this method is only available for image resources
/home/drm/WEBSITE/content/docs/Love/Anime_analysis/kiddygirland.md:162:1:

I substitute the .Page.RenderString method to the obsolete markdownify and now it’s fine. I’m probably missing key differences between those functions/methods, but I wonder, why did it complain now and mentioned the homepage which doesn’t use this shortcode ?!
It mentioned:

/home/drm/WEBSITE/content/_index.md:1:1:
---
title: Purpose of this website

and:

/home/drm/WEBSITE/themes/hugo-book/layouts/home/_markup/render-image.html:16:13:
{{ if gt $img.Width 1540 }}


Versions:
Linux drm-4236wv5 6.2.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 30 Mar 2023 14:51:14 +0000 x86_64 GNU/Linux
hugo v0.111.3-5d4eb5154e1fed125ca8e9b5a0315c4180dab192+extended linux/amd64 BuildDate=2023-03-12T11:40:50Z VendorInfo=gohugoio

1 Like

Thank you for posting this, it solved a problem for me as well

I was looking to have a multi-line figcaption.
The text of the figcaption was in frontmatter i.e

 imagecredit = '''
Photograph Harvey Metcalfe (1928), from Harry Price.\
Leaves from a Psychist's Case-Book (Victor Gollancz Ltd, 1933) [1]
'''

and it started working once I used this in the template
{{ $imagecredit := .Page.Params.imagecredit | markdownify }}

for the html

<figcaption>Image credit: {{ $imagecredit }}</figcaption>

so it rendered as:

Image credit: Photograph Harvey Metcalfe (1928), from Harry Price.
Leaves from a Psychist’s Case-Book (Victor Gollancz Ltd, 1933) [1]

Hugo version: hugo v0.145.0-666444f0a52132f9fec9f71cf25b441cc6a4f355+extended windows/amd64 BuildDate=2025-02-26T15:41:25Z VendorInfo=gohugoio