HTML in Variable

Is there a way to use a <br> in a Variable?
Right now Hugo prints the <br> as text, not as a linebreak.

For example:

+++
title = "My test"
slogan = "This line needs a <br>break"
+++

Thanks a lot!

In your template, try this:

{{ .Params.slogan | safeHTML }}

Also, you can do similar with Markdown:

{{ .Params.slogan | markdownify }}

Combine the above with TOML’s multiline support, and you can get niceness.

2 Likes

Do you have an example of what that parameter would look like using toml’s multiline support? I’ve tried a bunch of different things but keep getting errors. Thanks!

it’s 2021 :wink:

I’m a little behind. Basically what I’m trying to do is to have a summary variable in the post that has markdown (url’s) with newlines. I just can’t seem to get it to render without errors. Thanks!