From e2bff1f90a66648329e8f9de9aaff45fc87effbb Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 13 Aug 2020 11:10:58 -0600 Subject: [PATCH] updated canonical tag and added page title header partial --- layouts/partials/header.html | 12 +++--------- layouts/partials/header/canonical.html | 2 +- layouts/partials/header/title.html | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 layouts/partials/header/title.html diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 4513fd276..2b1ebe0b2 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -8,15 +8,9 @@ {{ partial "header/google-analytics-head.html" }} - {{ if eq $product nil }} - InfluxData Documentation - {{ else if eq $currentVersion nil}} - {{ (index .Site.Data.products $product).name }} Documentation - {{ else if eq (len $productPathData) 2 }} - {{ (index .Site.Data.products $product).name }} {{ $currentVersion }} Documentation - {{ else }} - {{ if .Params.seotitle }} {{ print .Params.seotitle " | " }} {{ else if .Title }} {{ print .Title " | " }} {{ end }}{{ (index .Site.Data.products $product).name }} {{ if $currentVersion }}{{print $currentVersion " " }}{{ end }}Documentation - {{ end }} + + {{ partial "header/title" . }} + diff --git a/layouts/partials/header/canonical.html b/layouts/partials/header/canonical.html index 221a282e1..0453b71a3 100644 --- a/layouts/partials/header/canonical.html +++ b/layouts/partials/header/canonical.html @@ -17,7 +17,7 @@ {{ $baseURL := replaceRE `\/$` "" .Site.BaseURL }} {{ $scratch.Set "canonicalURL" (print $baseURL .RelPermalink) }} -{{ if gt (len (findRE "[^/]+.*?" .RelPermalink)) 2 }} +{{ if ge (len (findRE "[^/]+.*?" .RelPermalink)) 2 }} {{ $scratch.Set "canonicalURL" (print $baseURL (replaceRE `v[0-9]\.[0-9]{1,2}` $latestMinorVersion .RelPermalink))}} {{ end }} diff --git a/layouts/partials/header/title.html b/layouts/partials/header/title.html new file mode 100644 index 000000000..7872f1e31 --- /dev/null +++ b/layouts/partials/header/title.html @@ -0,0 +1,25 @@ +{{ $scratch := newScratch }} +{{ $productPathData := findRE "[^/]+.*?" .RelPermalink }} +{{ $product := index $productPathData 0 }} +{{ $currentVersion := index $productPathData 1 }} + +{{ $scratch.Set "siteTitle" "InfluxData Documentation" }} +{{ if eq $product nil }} + {{ $scratch.Set "siteTitle" "InfluxData Documentation" }} +{{ else if eq $product "platform"}} + {{ $scratch.Set "siteTitle" "InfluxData Platform Documentation" }} +{{ else if eq $currentVersion nil}} + {{ $scratch.Set "siteTitle" (print (index .Site.Data.products $product).name " Documentation") }} +{{ else }} + {{ $scratch.Set "siteTitle" (print (index .Site.Data.products $product).name " " $currentVersion " Documentation") }} +{{ end }} + +{{ $scratch.Set "pageTitle" "" }} +{{ if or (eq $product "platform") (gt (len $productPathData) 2) }} + {{ $scratch.Set "pageTitle" (cond (ne .Params.seotitle nil) .Params.seotitle .Title) }} +{{ end }} + +{{ $pageTitle := $scratch.Get "pageTitle" }} +{{ $siteTitle := $scratch.Get "siteTitle" }} + +{{ $pageTitle }}{{ cond (ne (len $pageTitle) 0) " | " "" }}{{ $siteTitle }}