I have my own custom theme and I’m trying to add font awesome free v5 to it.
So I follow the instructions and download the font awesome zip, copy the css dir into assets/fontawesome/css and the webfonts dir into assets/fontawesome/webfonts.
I load the CSS like this, and I can verify that I get no 404’s for this.
{{- with resources.Get "fontawesome/css/fontawesome.min.css" }}
{{- if eq hugo.Environment "development" }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{- else }}
{{- with . | minify | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{- end }}
{{- end }}
{{- end }}
{{- with resources.Get "fontawesome/css/brands.min.css" }}
{{- if eq hugo.Environment "development" }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{- else }}
{{- with . | minify | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{- end }}
{{- end }}
{{- end }}
{{- with resources.Get "fontawesome/css/solid.min.css" }}
{{- if eq hugo.Environment "development" }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{- else }}
{{- with . | minify | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{- end }}
{{- end }}
{{- end }}
Looks like this in the generated HTML, and it’s below my own css which is 99% bulma.css. But I also tried putting font awesome above bulma.css.
<link rel="stylesheet" href="/fontawesome/css/fontawesome.min.css">
<link rel="stylesheet" href="/fontawesome/css/brands.min.css">
<link rel="stylesheet" href="/fontawesome/css/solid.min.css">
I can also verify that localhost:1313/fontawesome/webfonts exists and I can download the font files.
This url works: view-source:http://localhost:1313/fontawesome/css/brands.min.css
And this one works: view-source:http://localhost:1313/fontawesome/webfonts/fa-brands-400.eot
I don’t want to put fontawesome css into /css because I have my own css there.
I also tried using the CDN all.js version from font-awesome, so I assume the issue is with finding the webfonts files.
I also tried restarting the hugo live server. I can see that hugo server reacts to the webfonts being placed into the assets dir.
And finally I reference the fonts like this.
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-envelope"></i>
</span>
<span>My email</span>
</span>