Escaping Hugo shortcodes within Hugo markdown
All notes in this series:
- Automating hugo development with npm scripts
- normalize-scss with hugo
- Automatic image thumbnails in Hugo from static directory
- Escaping Hugo shortcodes within Hugo markdown
- Hugo tag and category pages
- Bind hugo to localhost for development
- Hugo 0.37 does not support h6 markdown heading
- Install Hugo testing distribution on Debian
- Hugo anchors next to headers
- Hugo: Migrating from Pygments to Chroma
- Hugo: Global resources
- Hugo: How to create a post series
If you naïvely try and write a post in Hugo about shortcodes using markdown, including code examples of the shortcodes, Hugo will still try to parse and render the shortcode. For example, if your markdown is as follows…:
…then Hugo will attempt to find the shortcode example-shortcode
and render it, even though it is inside a markdown code block! To avoid that happening, you can use the /*
and */
escape sequence, which is typically used to write comments in shortcodes or templates. To get the above example to render, you would have to do the following:
There appears to be no way within markdown to escape a code example of an escaped shortcode. So how did I get the above code example to escape? Perhaps ironically, though creating a new shortcode: