markdownhugo

Escape { } in codeblock regions of a markdown file with Hugo


I have a markdown file I want to render with Hugo and it contains example CMake code which uses { and } for variables (e.g., ${CMAKE_VERSION}). This seems to conflict with Hugo's shortcode handling that messes up the rendering for the rest of the content.

I cannot seem to properly escape the { } in any way, especially inside inline or block code blocks.

Inline example:

Some text blah blah blah `${CMAKE_VERSION}`

or a Block example:

Some test blah blah blah

```
Some block comment with a cmake variable such as ${CMAKE_VERSION}
```

How can I properly escape the { } to show up as code, without any sort of Hugo shortcode interjection?

Here are some live code links that show the issue: source, bad render.


Solution

  • Turns out hugo is compiling snippet properly but some javascript code is modifying your DOM layout. You can test yourself by visiting the same page and disabling the javascript in DevTools.

    enter image description here

    Edit: Seems this is the line causing it ?.