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" >}}
Let's stay connected!
If you like the post, subscribe to my newsletter to get latest updates:
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 , , , , or subscribe to my posts.