HUGO

Create HTML block in frontmatter

I would like to put on my index a bio description with links. I am using two different languages, so I have _index.md and _index.es.md files with some variables:

---
bio: I am a frontend developer....
homeText: Passionate about...
miniTitle: Personal website
---

Then I would like to create a html variable like this:

---
bio: I am a frontend developer....
homeText: Passionate about...
miniTitle: Personal website
html: You can know more <a href="/about">about me</a> or <a href="/contact">contact</a> me
---

How can I create something like this without spliting each sentence and link. I don´t want this:

---
bio: I am a frontend developer....
homeText: Passionate about...
miniTitle: Personal website
youCan: You can know more
linkAbout: /about
aboutLinkText: about me
or: or
linkContact: /contact
contactLinkText: contact
me: me
---

Any suggestion please?

Thanks a lot.

First of all there are no HTML variables in Hugo.

Hugo’s templates are context aware. Variables depend on the context.

Id est:

Page-, file-, taxonomy-, and site-level variables and parameters available in templates.


Second it is possible to enter HTML in a front matter parameter. The value of said parameter needs to be a string. When you call it you need to pipe it with the safeHTML function.

See the example at:

html was the name I gave to example variable, I did´t think Hugo had html variable.

About safeHTML, I insert the html into a paragraph tag:

<p>{{ .Params.bio }}</p>

And I find that paragraph is closed and my html is inserted after the paragraph. So it is not a solution in my case. Thanks for the help.

The way to do this would be: <p>{{ .Params.bio | safeHTML }}</p>

But where exactly are you trying to enter the above? From your comment about misplaced <p> tags it seems that you are trying to call this parameter through a content file and the Markdown processor gets in the way.

I am getting that parameter in my index.html in layouts folder.

Now it is working, I had 1 error. Anyway, I want in the bio a link starting with {{ .Site.BaseURL }}, and I can´t access to that variable in frontmatter, so I think it is not possible what I want.