From b88d13e7f050039641c2d50c52f1b4edafc29bcd Mon Sep 17 00:00:00 2001 From: Daniel Holbach Date: Sun, 6 Oct 2024 12:05:14 +0200 Subject: [PATCH] Add combine_page_and_site_title option If true, it will e.g. change the title tag for the Legal page to Legal | Jane Doe - Nutrition Coach & Chef Consultant Signed-off-by: Daniel Holbach --- exampleSite/hugo.toml | 4 ++++ layouts/partials/head.html | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/exampleSite/hugo.toml b/exampleSite/hugo.toml index b6c70c0..9961108 100644 --- a/exampleSite/hugo.toml +++ b/exampleSite/hugo.toml @@ -63,6 +63,10 @@ enableEmoji = true # Options used for automatic image generation. see: https://gohugo.io/content-management/image-processing/ image_options = "webp q90 lanczos photo" + + # Use "page_title | site_title" for tags + # e.g. <title>Legal | Jane Doe - Nutrition Coach & Chef Consultant + combine_page_and_site_title = false [params.footer] # Show contact icons for email/phone (if specified) in the footer of the page diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 2b83b7b..e349d0a 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,9 +1,13 @@ +{{ if and site.Params.combine_page_and_site_title .Title .Site.Title }} +{{ .Title | plainify }} | {{ .Site.Title | plainify }} +{{ else }} {{ with or .Title .Site.Title | plainify }} {{ . }} {{ end }} +{{ end }} {{ with resources.Get .Site.Params.favicon }} {{ end }}