Skip to content

Commit

Permalink
Make header configurable
Browse files Browse the repository at this point in the history
Add:

- Ability to header on home page.
- Ability to add CSS classes on header.
- Ability to disable on individual pages with a page parameter.
  • Loading branch information
undergroundwires committed Dec 25, 2021
1 parent 848b687 commit ff883ee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ paginate = 10
keywords = "homepage, blog"
images = [""]

# Configure header / top menu on top of each page
disableHeaderOnHome = false # Hides header on homepage
headerCssClasses = [ "" ] # Append CSS classes to header element

[taxonomies]
category = "blog"
tag = "tags"
Expand Down
7 changes: 7 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ disableHugoGeneratorInject = false
"Made with &#10084; by <a href=\"https://github.com/rhazdon\">Djordje Atlialp</a>"
]

# Custom header
[params.header]
# Set true to hide header on homepage
disableHeaderOnHome = false
# Add names to render additional CSS classes on <header> element
headerCssClasses = [ "" ]

# Colors for favicons
#
[params.favicon.color]
Expand Down
4 changes: 3 additions & 1 deletion layouts/partials/header.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<header class="header">
{{ if not (or .Params.disableHeader (and .Site.Params.header.disableOnHome .IsHome)) }}
<header class="header {{ if .Site.Params.header.cssClasses }}{{ range .Site.Params.header.cssClasses }} {{ . }}{{ end }}">
<span class="header__inner">
{{ partial "logo.html" . }}

Expand All @@ -19,3 +20,4 @@
</span>
</span>
</header>
{{ end }}

0 comments on commit ff883ee

Please sign in to comment.