Enable Raw Html in Hugo

Enable support of raw html

Hugo disables html element rendering by default, we need to enable it.

Enable for an entire site

Add below in the config file

[markup.goldmark.renderer]
unsafe= true

Enable for a single page

  • Create layout/shortcodes/unsafe.html with the following content: {{ .Inner }}

  • In the markdown page, use it like this,

    {{< unsafe >}}
    <ul>
        <li>First item</li>
        <li>Second item
        <li>Third item</li>
    </ul>
    {{< /unsafe >}}
    

    above will be rendered like this,

    • First item
    • Second item
    • Third item

Reference