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 index.md

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

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
GOOS="darwin"
GOARCH="amd64"
GOVERSION="go1.13.5"
{{</* 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" /*/>}}
{{</highlight>}}
1 Like