From f831fcae03aab91d6afa652d2f6cf00c1d7d0aab Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Thu, 10 Aug 2017 16:07:16 +0100 Subject: [PATCH] Use a partial to build the tag and RSS link title Code from Minimo theme: https://github.com/MunifTanjim/minimo/blob/master/layouts/partials/data/title Thanks @MunifTanjim. --- layouts/partials/data/title | 17 +++++++++++++++++ layouts/partials/header.html | 12 ++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 layouts/partials/data/title diff --git a/layouts/partials/data/title b/layouts/partials/data/title new file mode 100644 index 0000000..dd70e01 --- /dev/null +++ b/layouts/partials/data/title @@ -0,0 +1,17 @@ +{{- $title := .Title -}} +{{- $siteTitle := .Site.Title -}} +{{- $authorName := .Site.Author.name -}} +{{- $sep := ( .Site.Params.SEO.titleSeparator | default "•" ) -}} +{{- if .IsHome -}} + {{ $siteTitle }} +{{- else if eq .Kind "taxonomy" -}} + {{ title .Data.Singular }}: {{ $title }} {{ $sep }} {{ $siteTitle }} +{{- else if ( or .IsNode ( eq .Section "page" ) ) -}} + {{ $title }} {{ $sep }} {{ $siteTitle }} +{{- else -}} + {{- with $authorName -}} + {{ $title }} {{ $sep }} {{ . }} + {{- else -}} + {{ $title }} {{ $sep }} {{ $siteTitle }} + {{- end -}} +{{- end -}} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 712909a..ba7a2d4 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -1,13 +1,21 @@ <!DOCTYPE html> <html> <head> - <title>{{ .Site.Title }} + {{ partial "data/title" . }} {{ .Hugo.Generator }} {{ "" | safeHTML }} -

{{ .Site.Title }}

+ {{ with .RSSLink }} +

RSS

+ {{ end }} +