From 7b11f7fa772deb2e8e3b775dc823036fa7e29e45 Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Thu, 28 Jun 2018 22:58:54 +0200 Subject: [PATCH 1/3] Add a default Description for taxonomy pages Make use of the detection of the .Kind of page to have a default description for SEO purposes --- layouts/partials/head.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index f619f24..43e1064 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -8,7 +8,14 @@ {{- end }} -{{- with .Description | default .Params.subtitle | default .Summary }} +{{- if eq .Kind "taxonomyTerm" }} + {{- $text := printf "Overview of all pages by %s" .Data.Singular }} + {{- $.Scratch.Set "Description" $text }} +{{- else if eq .Kind "taxonomy" }} + {{- $text := printf "Overview of all pages with the %s #%s" .Data.Singular $.Title }} + {{- $.Scratch.Set "Description" $text }} +{{- end }} +{{- with .Description | default .Params.subtitle | default .Summary | default ($.Scratch.Get "Description") }} From 812e80392e5e526813aad9b9372e6ec787846f30 Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Fri, 29 Jun 2018 11:48:06 +0200 Subject: [PATCH 2/3] Add expanded title and description generation for taxonomy pages for SEO --- layouts/partials/head.html | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 43e1064..811a220 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,20 +1,29 @@ +{{- if eq .Kind "taxonomyTerm" }} + {{- range $key, $value := .Data.Terms.ByCount }} + {{- $.Scratch.Add "most_used" (slice $value.Name) }} + {{- end }} + {{- $description := printf "A full overview of all pages with %s, ordered by %s, such as: %s" .Data.Plural .Data.Singular ( delimit ( $.Scratch.Get "most_used" ) ", " ", and " ) | truncate 180 }} + {{- $.Scratch.Set "Description" $description }} + + {{- $title := printf "Overview of all pages with %s, ordered by %s" .Data.Plural .Data.Singular }} + {{- $.Scratch.Set "Title" $title }} +{{- else if eq .Kind "taxonomy" }} + {{- $description := printf "Overview of all pages with the %s #%s, such as: %s" .Data.Singular $.Title ( index .Pages 0).Title | truncate 160 }} + {{- $.Scratch.Set "Description" $description }} + + {{- $title := printf "Overview of all pages with the %s #%s" .Data.Singular $.Title }} + {{- $.Scratch.Set "Title" $title }} +{{- end }} -{{- with .Title | default .Site.Title }} +{{- with ($.Scratch.Get "Title") | default .Title | default .Site.Title }} {{ . }} {{- end }} -{{- if eq .Kind "taxonomyTerm" }} - {{- $text := printf "Overview of all pages by %s" .Data.Singular }} - {{- $.Scratch.Set "Description" $text }} -{{- else if eq .Kind "taxonomy" }} - {{- $text := printf "Overview of all pages with the %s #%s" .Data.Singular $.Title }} - {{- $.Scratch.Set "Description" $text }} -{{- end }} {{- with .Description | default .Params.subtitle | default .Summary | default ($.Scratch.Get "Description") }} From ac338d30b0e3f12f33544f66a38488ebeaf02b94 Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Fri, 29 Jun 2018 12:37:16 +0200 Subject: [PATCH 3/3] Restructure head parameter determination --- layouts/partials/head.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 811a220..20c7164 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -13,18 +13,21 @@ {{- $title := printf "Overview of all pages with the %s #%s" .Data.Singular $.Title }} {{- $.Scratch.Set "Title" $title }} +{{- else }} + {{- $.Scratch.Set "Description" ( .Description | default .Params.subtitle | default .Summary ) }} + {{- $.Scratch.Set "Title" ( .Title | default .Site.Title ) }} {{- end }} -{{- with ($.Scratch.Get "Title") | default .Title | default .Site.Title }} - {{ . }} +{{- with ($.Scratch.Get "Title") }} + {{ . }} - {{ $.Site.Title }} {{- end }} -{{- with .Description | default .Params.subtitle | default .Summary | default ($.Scratch.Get "Description") }} +{{- with ($.Scratch.Get "Description") }}