Nested Shortcodes converting to <pre><code> blocks

I’m trying to keep my markdown clean by shifting html production to short codes. So for example, some pseudocode:

{{< div >}}
{{< somehtmlcontent >}}
{{< /div >}}

Inside {{< somehtmlcontent >}} will be

<b>Helo my dear</b>
<a href=""></a>
{{ partial "somemorehtml.html" }}

So what happens is that Hello my dear renders fine, but the rest of {{< somehtmlcontent >}} is dumped side <pre><code></code></pre> and no longer functions as HTML.

I’ve tried fiddling with using {{% div %}} and piping to safeHTML and markdownify, and I tried looking into the Goldmark configuration, but nothing I did stopped Hugo from inserting <pre><code> tags in there.

I’ve read the following comment (Edit, sorry that was the wrong link):

It is suggested that structures like the {{< div >}} tag should be broken up into two short codes, one to open and one to close. Is that all we got?


1 Like

What is the output of hugo version?

Hugo Static Site Generator v0.74.3 linux/amd64 BuildDate: 2020-07-23T20:37:11Z

My best guess is that you have 4 chars (or multiple of that) of indentation where you insert your shortcode – which makes the markdown engine think it’s a code block.