Range and html commands inside

I have this partial code:

	{{ range $idx, $key := sort .Page.Params.item ".date" "desc" }}
	<div class="biobox">
	<img src="{{.imgsrc}}">
          <p> {{.title}}</p>
	</div>
    {{end}}

In addition, In my content folder I have this item:

item:
 -  title: "Lorem ipsum dolor sit amet, <i> consectetur adipiscing elit</i>,sed do eiusmod tempor "
    imgsrc: "https://duckduckgo.com/i/7cc56a9e.png"

I Expected the phrase inside the to be in italic. However, I see the <i> and </i> in my output.
Any way to let Hugo know that these are HTML commands?

Hugo has nothing to do with this.

This is the upstream go txt template package escaping HTML in front matter parameter strings for security reasons.

Try the following in the partial template: <p> {{ safeHTML .title }}</p>

Also have a look at: safeHTML | Hugo

Hm…if you are seeing the <i> element in the page source then your issue is a CSS one. Most likely in your project’s stylesheet something overrides the way that an <i> element is displayed in browsers by default.

Again Hugo has nothing to do with this.

If you are still unable to solve this then you need to provide a repo with a sample project that replicates the issue you encountered.

P.S. Also note that we do not provide support for CSS issues in this forum.

safeHTML did the trick.
Thank you very much!

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