Escaping Hugo Shortcode
In the rare case you might need to escape (i.e., prevent from executing)
a shortcode in a Hugo markdown (.md) file, and display the shortcode as
{{< myshortcode >}} you will probably find that escaping the double curly
braces with \ is not working for this, producing a result similar to this
{{< myshortcode >}} or this
{{< myshortcode >}}
or that the shortcode is executed nevertheless.
A simple method that works at the time of writing, is adding /* after the
opening double curly braces and the angle bracket or percent sign
(i.e., {{>/* or {{% and adding */ after the closing angle bracket
or percent sign and double curly braces (i.e., */>``}} or %}}).
So, if for example, you have the shortcode myshortcode and you want to
use it to a code highlight without being executed during page building
from the Hugo engine, you should try including it in your markdown file as:
```md
{{</* myshortcode */>}}
```
The above will produce an output like the following:
{{< myshortcode >}}
References for further reading:
Chaos - 老碼農的筆記