How to show shortcode as highlighted code?

Can’t find this in the docs or older questions, so I’ll ask.

How do I show/render highlighted code that contains a shortcode in my Markdown (and preventing the shortcode from being processed?

My intuition tells me something like this could work inside my

{{<highlight go-html-template>}}
{{<post-image image='hero-image.png' />}}

But my custom shortcode post-image is executed instead of just shown as is.

My environment:

Hugo Static Site Generator v0.62.2/extended darwin/amd64 BuildDate: unknown
{{</* myshortcode */>}}<p>Hello <strong>World!</strong></p>{{</* /myshortcode */>}}
1 Like

Thank you bep! Tried something similar from one of your earlier replies, must have messed up the syntax somehow. For a self-closing shortcode it then becomes:

{{<highlight go-html-template>}}
{{</*post-image image="hero-image.png" /*/>}}
1 Like