Switch between HTML and markdown in one .md file


#1

Hey All,

So I know you can use HTML in Hugo as well as Markdown. One stumbling block I have run into is that, from what I can tell, once you introduce HTML, everything else inside the opening and closing tags will be processed as HTML i.e.

<div class="something">
 ## Headline <!-- this will simply be output as ## Headline and not parsed as markdown -->
</div>

Is there a way to manually, via a directive maybe, tell Hugo to treat a block as Markdown even though it is wrapped in an HTML tag? Thanks!


#2

You could do this with a shortcode.

Usage:

{{< foo >}}
## Header
{{</ foo>}}

Definition:

<div class="something">
{{ .Inner | markdownify }}
</div>

#3

Thanks so much @zwbetz, that worked perfectly!