TIL: Include HTML file in a post with Hugo
Shortcode are simple snippets inside your content files calling built-in or custom templates.
Include HTML file in a post
Create layouts/shortcodes/include-html.html
:
{{ $file := .Get 0 }}
{{ (printf "%s%s" .Page.File.Dir $file) | readFile | safeHTML }}
Then use it in your content files:
{{โ< include-html "embedded.html" >}}
Author
I'm Oliver Nguyen. A software maker working mostly in Go and JavaScript. I enjoy learning and seeing a better version of myself each day. Occasionally spin off new open source projects. Share knowledge and thoughts during my journey. Connect with me on , , , and .