HomeAboutPostsTagsProjectsRSS

Updated
Words228
TagsRead1 minute

A nice way to add arbitrary HTML tags in Hugo site markdown content.

Create a content.html in layouts/partials

{{
.
| replaceRE `\{\^([^}]*)\}` "<sup>$1</sup>"
| replaceRE `\{\_([^}]*)\}` "<sub>$1</sub>"
| replaceRE `\{\#([^}]*)\}` "<kbd>$1</kbd>"
| replaceRE `\{\!([^}]*)\}` "<mark>$1</mark>"
| replaceRE `\{\=([^}]*)\}` "<cite>$1</cite>"
| replaceRE `\{\+([^}]*)\}` "<ins>$1</ins>"
| replaceRE `\{\$([^}]*)\}` "<var>$1</var>"
| safeHTML 
}}

and use the partial html template {{ partial "content.html" .Content }} to render the HTML

Get missing inline HTML tags in Markdown without enabling HTML - tips & tricks - HUGO