Hugo Shortcode to Render HTML
Shekhar Chandra
Posted on July 14, 2021
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>` >}}
💖 💪 🙅 🚩
Shekhar Chandra
Posted on July 14, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
webdev Understanding HTTP, Cookies, Email Protocols, and DNS: A Guide to Key Internet Technologies
November 30, 2024