From 4f722e0c6d05755ee47ca748b03ae6bbd2f7ccf6 Mon Sep 17 00:00:00 2001 From: Reorx Date: Thu, 5 May 2022 18:47:00 +0800 Subject: [PATCH] add site title after title --- layouts/partials/head.html | 22 +++++++++++---------- layouts/partials/templates/opengraph.html | 5 ++++- layouts/partials/templates/schema_json.html | 5 +++-- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index d855306..43ef99e 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -8,7 +8,11 @@ {{- end }} {{- /* Title */}} -{{ if .IsHome }}{{ else }}{{ if .Title }}{{ .Title }} | {{ end }}{{ end }}{{ site.Title }} +{{- $pageTitle := site.Title }} +{{- if (and .Title (not .IsHome)) }} + {{- $pageTitle = printf "%s | %s" .Title $pageTitle }} +{{- end }} +{{ $pageTitle }} {{- /* Meta */}} {{- if .IsHome }} @@ -73,19 +77,17 @@ {{- /* https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started */}} {{- if .Params.cover.image }} - - - - - -{{- else -}} - {{- template "_internal/twitter_cards.html" . -}} {{- end -}} + + + + + -{{- template "partials/templates/opengraph.html" . }} +{{- template "partials/templates/opengraph.html" (dict "page" . "pageTitle" $pageTitle) }} -{{- template "partials/templates/schema_json.html" . }} +{{- template "partials/templates/schema_json.html" (dict "page" . "pageTitle" $pageTitle) }} {{- partial "extend_head.html" . }}