Using <!--more--> as a content summary separator doesn't work with complex HTML code

Hi everyone,

I’m trying to create a list of articles, with a little extract from each article that would include HTML code in it (so that even images would be included in the .Summary variable). For some reason, I only get the image from the example. It breaks right before the opening <p> tag

This is how the page itself looks like:

---
title: "Page title"
date: 2020-06-17T13:56:03Z
draft: false
---
<div class="row">
    <div class="col-md-12">
        <img style="max-width: 20%; float: right; margin: 20px; margin-top: 40px;"src="/files/image.png">
        <p class="lead">
                some text goes here
        </p>

<!--more-->

        <p>
                some more text goes here
        </p>
    </div>
</div>

And here’s the layout:

<div class="article_content">
    <div class="col-md-12">
       {{ .Summary }}
    </div>
</div>

Any ideas why? Or what can be done so that I won’t need to run regex on .Content? Running Hugo 0.54.0 on Debian 10. Tried to run Hugo 0.79 but that didn’t help, it actually broke a lot of other things on my site…

Any ideas would be really appreciated!

Thanks!

put it on a single line

</p>
<!--more-->
<p>

or with blank lines

</p>

<!--more-->

<p>

Hi @ju52, I’ve done that, it doesn’t help at all. Edited my question for clarity.

quote from the doc

You can customize how HTML tags in the summary are loaded using functions such as plainify and safeHTML .

my last guess

{{ .Summary | safeHTML}}

What ist in the generated files?

can you give us a repository (sample) to help? guessing is no big help :wink:

I cannot reproduce your issue.

By default the Goldmark markdown processor omits HTML in content files.
Have you enabled the unsafe parameter in the project config?

i.e.

[markup.goldmark.renderer]
    unsafe = true
1 Like

@alexandros That did the trick!

I’ve upgraded to Hugo 0.79 anyway, from what I understood Hugo 0.54 used Blackfriday as the default markup renderer, so switching to Goldmark with those 2 little lines of configuration just made everything work! :slight_smile:

Thank you everyone.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.