HUGO

HTML tag doesn't work in site parameters

Hi there,
In config.toml file, I set some html tags for site parameters, but it doesn’t work.

[params]
description = "Hello and <br /> This is the second line, check [details](https://some.com)."

Both <br /> and the later link do not work.

Are there something wrong?
Thanks for any help.

You need to post how you are using site.Params.description. It probably needs something like safeHTML.

Thanks for the note. I am using Elate theme

Here is the config.toml

Here is the hero.html that uses the Params.hero.subtitle as following:

<section id="fh5co-home" data-section="home" style="background-image: url(images/full_image_2.jpg);" data-stellar-background-ratio="0.5">
		<div class="gradient"></div>
		<div class="container">
			<div class="text-wrap">
				<div class="text-inner">
					<div class="row">
						<div class="col-md-8 col-md-offset-2">
							<h1 class="to-animate">{{ with .Site.Params.hero.title }}{{ . | markdownify }}{{ end }}</h1>
							<h2 class="to-animate">{{ with .Site.Params.hero.subtitle }}{{ . | markdownify }}{{ end }}</h2>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="slant"></div>
	</section>

One note, this used to work fine but stop working some time ago. This theme has not been updated for over 2 years, don’t know if something about this.

It worked when building the site with v0.59.1 and earlier, which use the Blackfriday markdown processor.

Hugo v0.60.0 was released in November 2019, replacing the Blackfriday markdown processor with Goldmark. By default, Goldmark does not trust HTML within your markdown, and replaces each instance with <!-- raw HTML omitted -->.

Open the problem page in your browser, view source, and search for “raw HTML omitted”.

If you trust the authors of the markdown, place this in your site configuration:

[markup.goldmark.renderer]
unsafe = true

https://gohugo.io/getting-started/configuration-markup#goldmark

unsafe

By default, Goldmark does not render raw HTMLs and potentially dangerous links. If you have lots of inline HTML and/or JavaScript, you may need to turn this on.

You can audit your site prior to deployment to find problems like this.

{{ with .Site.Params.hero.subtitle }}{{ . | markdownify | safeHTML }}{{ end }}

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