Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use default favicon in custom site #3

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,16 @@ git submodule update --remote --merge

### 🎨 Favicon

Create `[SITEROOT]/layouts/partials/favicon.html` to override theme's favicon.
In `config.toml`:

If you want to use a simple emoji favicon, just copy the following code to your `favicon.html`:
```toml
[params]
replaceFavicon = true
```

Then, create `[SITEROOT]/layouts/partials/custom_favicon.html` to override the theme's default favicon.

If you want to use a simple emoji favicon, just copy the following code to your `custom_favicon.html`:

```html
<link
Expand All @@ -73,9 +80,8 @@ If you want to use a simple emoji favicon, just copy the following code to your
```
See `layouts/partials/favicon.html` for an example.

Otherwise, you can provide your favicon, or generate it using an online service, for example [realfavicongenerator.net](https://realfavicongenerator.net/). \
See `exampleSite/layouts/partials/favicon.html` and `exampleSite\static\assets\favicon` for an example.

Otherwise, you can provide your own favicon or generate it using an online service, for example [realfavicongenerator.net](https://realfavicongenerator.net/). \
See `exampleSite/layouts/partials/custom_favicon.html` and `exampleSite/static/assets/favicon` for an example.

### ❌ License, toc and comments

Expand Down
3 changes: 3 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ summaryLength = 100 # Custom summary length, add <!--more--> in post file to cus
# Copyright
copyrightStartYear = "2024"

# favicon
replaceFavicon = false

# Open Graph & Twitter Card variables
# You can also set description and images in post front matter individually
description = "A minimal Hugo theme with nice theme color."
Expand Down
4 changes: 4 additions & 0 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
{{ hugo.Generator }}

<!-- favicon -->
{{ if .Site.Params.replaceFavicon }}
{{ partial "custom_favicon.html" . }}
{{ else }}
{{ partial "favicon.html" . }}
{{ end }}
<!-- seo metadata -->
{{ if and (.IsHome) (.Site.Params.subTitle) }}
<title>{{ .Site.Title }} - {{ .Site.Params.subTitle }}</title>
Expand Down