Featured image of post Allow Raw HTML in Hugo Markdown

Allow Raw HTML in Hugo Markdown

Learn how to enable raw HTML in Hugo Markdown with YAML, TOML, and JSON examples, plus the security trade-off and when not to enable it.

Hugo’s Goldmark Markdown renderer does not render raw HTML by default. If you need it, set markup.goldmark.renderer.unsafe to true in your site configuration. Hugo supports YAML, TOML, and JSON configuration files. For example, in hugo.yaml:

1
2
3
4
markup:
  goldmark:
    renderer:
      unsafe: true

In hugo.toml:

1
2
[markup.goldmark.renderer]
  unsafe = true

Or in hugo.json:

1
2
3
4
5
6
7
8
9
{
  "markup": {
    "goldmark": {
      "renderer": {
        "unsafe": true
      }
    }
  }
}

The default is false. Setting unsafe: true allows raw HTML in Markdown to pass through, weakening Hugo’s content trust boundary. Do not enable it when the site processes Markdown from untrusted contributors or external input. Use it only when you control and review the content, and understand the implications. For complex layouts, a shortcode or an HTML content file may be a better fit.

References: Configure markup · Hugo’s security model

Licensed under CC BY-NC-SA 4.0
Last updated on 2026/11/23 00:00 UTC
comments powered by Disqus