Skip to content

Commit

Permalink
Add support for custom social icons
Browse files Browse the repository at this point in the history
  • Loading branch information
lordmathis committed Mar 21, 2023
1 parent fb0a4e1 commit 9031afb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ You can also add social links
key = 0
name = "github"
url = "https://github.com/gohugoio"
icon = "fa-brands fa-github" # Add link to your icon font to `layouts/partials/custom-head.html`

[[params.social]]
key = 1
Expand Down Expand Up @@ -67,6 +68,9 @@ To add a menu item add `[[menu.header]]` item to `config.toml`. For example:
url = "/posts"
```

To use icons for social links, you also need to add the link to icon font to custom-head.html


## Custom Head

To use custom icons, css, js or other resources create `layouts/partials/head-custom.html` and add your links there.
To use custom icons, css, js or other resources create `layouts/partials/custom-head.html` and add your links there.
8 changes: 7 additions & 1 deletion layouts/partials/social.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
<ul>
{{ range sort .Site.Params.social "key"}}
<li>
<a href="{{ .url | safeURL }}">{{ .name }}</a>
{{ if isset . "icon" }}
<a href="{{ .url | safeURL }}" aria-hidden="true" title="{{ .name }}">
<i class="{{ .icon }}"></i>
</a>
{{ else }}
<a href="{{ .url | safeURL }}">{{ .name }}</a>
{{ end }}
</li>
{{ end }}
</ul>
Expand Down

0 comments on commit 9031afb

Please sign in to comment.