Hugo

Hugo 0.58.1 Markdown not rendering within shortcode

Recently I’ve updated to hugo 0.58.1 from 0.54.0; I have a shortcode that uses the .Inner parameter as such: {{ .Inner | markdownify | safeHTML }}.
Within the shortcode I have the: {{$_hugo_config:={ "version": 1 }}} - with the tildes - code to use the old behaviour rendering markdown inside of shortcodes.

However, when ever viewing lists or images within the shortcode, they are not rendered.

The shortcode acts as a collapsing or “accordion” component for content.

Example code:
{{%expand “name”%}}
Here is a list of items:
-item 1
-item 2
-item 3
{{%/expand %}}

the markdown list is rendered as:
Here is a list of items: -item 1-item 2-item 3

where it should be rendered as:
Here is a list of items:

  • item 1
  • item 2
  • item 3

Any help?

Seems like you need to incorporate markdownify somewhere in your shortcode.

1 Like

I should have mentioned markdownify and safeHTML are both present. The inner is as such:
{{ .Inner | markdownify | safeHTML }}

It should also be worth mentioning I’m using mmark as the pages markdown processor, rather than Hugo’s blackfriday. Both are experiencing the issue. I’ve ran in draft and cleared cache but still no avail.

I ended up solving the problem. For some odd reason, the theme I was using has a shortcode (expand) - when making a custom shortcode and giving it the same naming convention still used the theme’s shortcode and not my custom one. I changed the name of the custom shortcode, used it where required and markdown was rendered again. Thanks.