Hugo Shortcode to Render HTML


Problem

Adding raw HTML in hugo content doesn’t render at all in static page.

Solution

Add a shortcode in layout folder to handle HTML in a safe manner.

<!-- renderhtml.html -->
{{- $content := .Get "content" | default (.Get 0) -}}
<div>
    {{ $content | safeHTML }}
</div>

Now it can be included in any mardown content file as, Just put the raw HTML in between the ticks.

{{ < renderhtml `<div></div>` >}}