r-markdownhugoblogdownhugo-shortcode

Can I escape a shortcode from a Hugo theme from blogdown


I'm using a hugo theme: https://github.com/shawnohare/hugo-tufte which allows for the use of the shortcode {{% marginnote %}}...{{% /marginnote %}} to create a margin note.

I want to output the actual text {{% marginnote %}}...{{% /marginnote %}} on my final page, but all my attempts to escape the shortcode have come up short.

Wrapping it with 's as you would in Hugo is not successful. Neither is escaping those quotes Nor wrapping it in a code block.


Solution

  • To escape Hugo shortcode calls, use syntax like this:

    {{%/* marginnote */%}}
    ...
    {{%/* /marginnote */%}}
    

    I wrote about this in Escaping Hugo shortcodes in my Hugo Tips and Fragments article.

    I learned about this in discourse.gohugo.io in the thread How is the Hugo Doc site showing shortcodes in code blocks?.