Shortcode syntax example within a code block is being executed

Hi there,

I was writing a note about Hugo, just trying to explain how templates can be called and I wrote something like this in the Markdown file:

- Partial: `{{ partial "<PATH>/<PARTIAL>.html" . }}`
- Shortcode: `{{% shortcodename parameters %}}`

When I start hugo server or hugo it throw an error:

hugo server
Start building sites …
hugo v0.87.0-B0C541E4+extended windows/amd64 BuildDate=2021-08-03T10:57:28Z VendorInfo=gohugoio
Error: Error building site: "C:\Users\Hippocrene\projects\blog\yuanyiblog\content\posts\hugo.md:209:17": failed to extract shortcode: template for shortcode "shortcodename" not found

I wonder why my content in code blocks has been executed? How can I avoid this?

Thank you.

I have amended the topic title because the issue pertains to the shortcode syntax -and not the partial-.

Also I can reproduce it, but I don’t have the time to debug it.

The Markdown processor was upgraded in the latest release.
However this issue also happens when the HTML delimiter is used within a content file’s code block:

e.g.

`{{< shortcodename parameters >}}`

Hopefully the others can have a look.

Shortcodes are always evaluated, even within code blocks. This has always been the case (at least since v0.54.0). It is not new behavior.

When documenting the use of a shortcode, use this notation:

My example:

```html
{{</* foo */>}}
{{%/* bar */%}}
```

This will render:

image

4 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.