Skip to content

Commit

Permalink
feat: support user-supplied head partial (#244)
Browse files Browse the repository at this point in the history
If theme user creates a "custom-head.html" partial, it will be included
at the end of the <head> section.
  • Loading branch information
jannes authored Oct 28, 2024
1 parent 21b814b commit 6b0e47a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div align=center>
<div align=center>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/hugo-sid/hugo-blog-awesome/main/assets/icons/book-icon-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/hugo-sid/hugo-blog-awesome/main/assets/icons/book-icon-light.svg">
<img alt="Hugo blog awesome logo" src="https://raw.githubusercontent.com/hugo-sid/hugo-blog-awesome/feat/logo-change/assets/icons/book-icon-light.svg" />
</picture>

</div>
<h1 align=center> Hugo Blog Awesome | <a href="https://hba.sid.one" target="_blank" rel="nofollow">Demo link</a></h1>

Expand Down Expand Up @@ -220,6 +220,11 @@ To enable go to top button on blog posts, set `goToTop` to `true` in `hugo.toml`
goToTop = true
```

### Add custom HTML to `<head>` section

To add custom HTML to the `<head>` section, create a partial named `custom-head.html`.
The contents of this partial will be inserted at the end of the `<head>` section.

## Content

### Posts
Expand Down
4 changes: 4 additions & 0 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@
{{ template "_internal/google_analytics.html" . }}
{{- end -}}

{{/* Extend head with user supplied partial */}}
{{ if templates.Exists "partials/custom-head.html" }}
{{ partial "custom-head.html" . }}
{{ end }}
</head>

0 comments on commit 6b0e47a

Please sign in to comment.