Alternative to <br> tag for line break in message attribute of config.toml after migrating build image from Trusty to Focal?

Hi there!

Subsequent to the deprecation notice sent out this morning relating to the Trusty build image, I successfully (thanks to the help of coelmay and hrishikesh) migrated the build image for my site built on the Hugo theme

to the latest Focal build image.

However, subsequent to the migration for some reason the
tag no longer works to render line breaks for in a block of address text in the message attribute of the Contact section of the config.toml file for my Hugo theme

Previously,

# Contact section
[params.contact]
  enable = true
  title = "Contact Us"
  message = "Address line 1<br>Address line 1<br>Address line 1<br>Address line 1<p>Tel line +123456789"

gave the desired effect.

But subsequent to the migration, when doing a test deployment, the line breaks no longer render in the Deploy Preview

Any ideas on how I can get this to format properly again?

Thanks!

Hi @sp_ppl,

Could you try \n instead of <br>?

renders as a space but not as a line break

at least in the Deployment preview… Might it make any difference if I do a full production publish?

Well, that should have worked.

Maybe you’d have some luck by changing it to \r\n, but you could also try enabling usage HTML from Hugo’s settings: Configure Markup | Hugo

1 Like

Unfortunately no luck with \r\n

But so if I added

[markup]
[markup.goldmark]
[markup.goldmark.extensions]
definitionList = true
footnote = true
linkify = true
strikethrough = true
table = true
taskList = true
typographer = true

[markup.goldmark.parser]
autoHeadingID = true
autoHeadingIDType = 'github'
[markup.goldmark.parser.attribute]
block = false
title = true


[markup.goldmark.renderer]
hardWraps = false
unsafe = false
xhtml = false

to my config.toml file and change the unsafe = line to

unsafe = true

that’d work?

(sorry if my questions are totally entry-level)

It should since that’s what Hugo uses to parse Markdown.

1 Like

It works!! But not just with

unsafe = true

But I also had to change the

hardWraps = false

line to

hardWraps = true

to get the desired effect.

(Just a side question: given that the value is now set to unsafe does that mean there is any major security risk associated with configuring the markdown in that way?)

Thanks once again for all your help!

You just have to make sure, not to write any untrusted JavaScript in your Markdown as that would get injected in the final output. Other than that, you’re good to go.

1 Like

okay that’s great thanks!