# Code fence issue on upgrade from 0.59.1 to 0.60.0+

**URL:** <https://discourse.gohugo.io/t/code-fence-issue-on-upgrade-from-0-59-1-to-0-60-0/33615>\
**Category:** support\
**Tags:** highlight\
**Created:** [June 29, 2021, 6:28pm UTC](https://discourse.gohugo.io/t/code-fence-issue-on-upgrade-from-0-59-1-to-0-60-0/33615 "2021-06-29T18:28:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![raybellis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/raybellis/32/14700_2.png) [@raybellis](https://discourse.gohugo.io/u/raybellis)\
**Post date:** [June 29, 2021, 6:28pm UTC](https://discourse.gohugo.io/t/code-fence-issue-on-upgrade-from-0-59-1-to-0-60-0/33615/1 "2021-06-29T18:28:47Z")

</div>

On our site (which doesn’t use themes, but custom layout from a third party) we’re looking to upgrade from the now quite aged 0.59.1 release.

However our code fence blocks get rendered into HTML _really_ weirdly. The first chunk of code is always OK, but anything after the first blank link gets rendered as multiple `<p>` elements, sometimes with nested `<pre>` elements. In these blocks white space isn’t preserved, and the odd nesting of elements also completely messes with our CSS (although I could resolve that).

Bizarrely, if I build a brand new Hugo site and throw the same markdown content at it with any version I’m unable to recreate the problem - each line of code gets the expected `<span>` element.

As far as I can see we’ve no render-specific options in our config files except for `markup.goldmark.renderer.unsafe = true`

What could there possibly be in our site’s configuration that causes the code fence output to alter so radically?

Hugo 0.84.2

 ![hugo-0.84.2](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/f/fd568325ae83e1f47c12b4e71ee8032d1a87ef1e.png)

---

<div class="post-metadata">

**Author:** ![raybellis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/raybellis/32/14700_2.png) [@raybellis](https://discourse.gohugo.io/u/raybellis)\
**Post date:** [June 29, 2021, 6:34pm UTC](https://discourse.gohugo.io/t/code-fence-issue-on-upgrade-from-0-59-1-to-0-60-0/33615/2 "2021-06-29T18:34:09Z")

</div>

Here’s how it looked in 0.59.1 (without syntax highlighting)

 ![hugo-0.59](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/6/6addfe72b5f4923c6e4720b68aa81f931b050afe.png)

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 29, 2021, 6:50pm UTC](https://discourse.gohugo.io/t/code-fence-issue-on-upgrade-from-0-59-1-to-0-60-0/33615/3 "2021-06-29T18:50:20Z")

</div>

> [@raybellis](#):
>
> Bizarrely, if I build a brand new Hugo site and throw the same markdown content at it with any version I’m unable to recreate the problem - each line of code gets the expected `<span>` element.

Given that, I think it’s a tall order to expect anyone to guess what’s up with your old site without seeing the source. The devil is in the details.

---

<div class="post-metadata">

**Author:** ![raybellis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/raybellis/32/14700_2.png) [@raybellis](https://discourse.gohugo.io/u/raybellis)\
**Post date:** [June 29, 2021, 7:28pm UTC](https://discourse.gohugo.io/t/code-fence-issue-on-upgrade-from-0-59-1-to-0-60-0/33615/4 "2021-06-29T19:28:09Z")

</div>

I believe I’ve found the problem.

It appears to be due to our third party “designer” always using:

`{{ .Content | markdownify }}`

with my understanding of that being that all page contents were being fed through the markdown engine twice.

This might also explain why rendering was broken on pages that didn’t even have raw HTML when `unsafe` was set to false.

Is that pipe into `markdownify` something that was actually required in earlier versions, or was this always incorrect markup?

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [June 29, 2021, 8:13pm UTC](https://discourse.gohugo.io/t/code-fence-issue-on-upgrade-from-0-59-1-to-0-60-0/33615/5 "2021-06-29T20:13:31Z")

</div>

[`markdownify`](https://gohugo.io/functions/markdownify/#readout) was never a requirement in Hugo templates, it simply:

> Runs the provided string through the Markdown processor.

Markdown and HTML are both acceptable content file formats in Hugo, HTML files do not get processed by the Markdown processor and Markdown files can contain raw HTML syntax if the `unsafe` flag is provided in a project’s config.

Also `{{ .Content | markdownify }}` is not an incorrect construct per se, it all depends on the project’s context.

---

<div class="post-metadata">

**Author:** ![raybellis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/raybellis/32/14700_2.png) [@raybellis](https://discourse.gohugo.io/u/raybellis)\
**Post date:** [June 29, 2021, 8:51pm UTC](https://discourse.gohugo.io/t/code-fence-issue-on-upgrade-from-0-59-1-to-0-60-0/33615/6 "2021-06-29T20:51:59Z")

</div>

Sure - we have plenty of other templates that do pass individual chunks of data (from `with`, or `range`, etc) into `markdownify`. The problematic ones seem to be the ones where the entire `.Content` derived from a `.md` file was being processed twice.
