How to add fontawesome icon to title in front matter?

I’m not a web dev, I have just started a blog. I wondered what’s the best way to add a fontawesome icon to the title of a post in front matter? Something like this maybe?

---
title: ":(fas fa-exclamation-triangle fa-fw): Careful with this dangerous thing"
subtitle: "It might bite you"
date: 2021-03-16T13:41:54Z
lastmod: 2021-03-16T13:41:54Z
draft: true
---

I’m using the LoveIt theme and my blog source code is here GitHub - markallisongit/blog: my blog

Thanks for any pointers.

It is possible to do exactly what you are asking, but I wouldn’t. You are polluting the actual title with information about the title (metadata). Instead, I would do something like:

title: "My Title"
warning: true

Then in the template(s), do something like:

{{ if .Params.warning }}
  <i class='fas fa-exclamation-triangle fa-fw'></i>
{{ end }}
{{ .Title }}
4 Likes

or even more flexible:

title: "my title"
icon: "exclamation-triangle"

in template:

{{ with .Params.icon }}
  <i class='fas fa-{{ . }} fa-fw'></i>
{{ end }}
{{ .Title }}

leave the icons out and none is printed, else the one you choose is printed.

2 Likes

Or use an emoji :warning:

1 Like