TIL - raw HTML in Hugo
TIL, Today I Learned, is more of a "I just figured this out: here are my notes, you may find them useful too" rather than a full blog post
I'm using Hugo [1] for this website setup [2] and find it very satisfying. I can write all my content in reStructured Text [3] and create a website out from it.
Today I needed to add a part of raw HTML into one of my pages and that was when I found Shortcodes [4] in which is very useful.
It is also easy to create your own shortcodes. In my case, I created layouts/shortcodes/rawhtml.html containing:
<!-- raw html --> {{.Inner}}
Now I can add raw HTML to my pages using the rawhtml tag, for examle:
{< rawhtml >} <iframe width="100%" height="500" src="https://docs.google.com/spreadsheets/d/e/2PACX-1vT_kO5y3AssyITYdDszNhORVHz5xAWf-WLcKuh50XV-fGqWTaIz9ICT1c0fGrqyl5U-3dAGXaoDkWlY/pubhtml?gid=0&single=true&widget=true&headers=false"></iframe> {< / rawhtml >}
Which will end up like this:
Of course, this isn't the best ( nor safest) way to use shortcodes. There are several reference implementations [5] in the repository that may be worth a look.