add site title after title

This commit is contained in:
Reorx 2022-05-05 18:47:00 +08:00
parent e1216a8d00
commit 4f722e0c6d
3 changed files with 19 additions and 13 deletions

View File

@ -8,7 +8,11 @@
{{- end }} {{- end }}
{{- /* Title */}} {{- /* Title */}}
<title>{{ if .IsHome }}{{ else }}{{ if .Title }}{{ .Title }} | {{ end }}{{ end }}{{ site.Title }}</title> {{- $pageTitle := site.Title }}
{{- if (and .Title (not .IsHome)) }}
{{- $pageTitle = printf "%s | %s" .Title $pageTitle }}
{{- end }}
<title>{{ $pageTitle }}</title>
{{- /* Meta */}} {{- /* Meta */}}
{{- if .IsHome }} {{- if .IsHome }}
@ -73,19 +77,17 @@
{{- /* https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started */}} {{- /* https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started */}}
{{- if .Params.cover.image }} {{- if .Params.cover.image }}
<meta name="twitter:card" property="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" /> <meta name="twitter:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
<meta name="twitter:title" content="{{ .Title }}" />
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}" />
<meta name="twitter:site" content="@novoreorx" />
<meta name="twitter:creator" content="@novoreorx" />
{{- else -}}
{{- template "_internal/twitter_cards.html" . -}}
{{- end -}} {{- end -}}
<meta name="twitter:card" property="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="{{ $pageTitle }}" />
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}" />
<meta name="twitter:site" content="@novoreorx" />
<meta name="twitter:creator" content="@novoreorx" />
{{- 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" . }} {{- partial "extend_head.html" . }}
<noscript> <noscript>

View File

@ -1,4 +1,5 @@
<meta property="og:title" content="{{ .Title }}" /> {{ with .page }}
<meta property="og:title" content="{{ $.pageTitle }}" />
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" /> <meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" /> <meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" /> <meta property="og:url" content="{{ .Permalink }}" />
@ -50,3 +51,5 @@
{{- /* Facebook Page Admin ID for Domain Insights */}} {{- /* Facebook Page Admin ID for Domain Insights */}}
{{- with site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }} {{- with site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}
{{- end }}

View File

@ -1,3 +1,4 @@
{{ with .page }}
{{ if .IsHome }} {{ if .IsHome }}
<script type="application/ld+json"> <script type="application/ld+json">
{ {
@ -60,7 +61,7 @@
{ {
"@context": "https://schema.org", "@context": "https://schema.org",
"@type": "BlogPosting", "@type": "BlogPosting",
"headline": {{ .Title | plainify}}, "headline": {{ $.pageTitle | plainify}},
"name": "{{ .Title | plainify }}", "name": "{{ .Title | plainify }}",
"description": {{ with .Description | plainify }}{{ . }}{{ else }}{{ .Summary | plainify }}{{ end -}}, "description": {{ with .Description | plainify }}{{ . }}{{ else }}{{ .Summary | plainify }}{{ end -}},
"keywords": [ "keywords": [
@ -70,7 +71,6 @@
{{ range $i, $e := .Params.tags }}{{ if $i }}, {{ end }}{{ $e }}{{ end }} {{ range $i, $e := .Params.tags }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}
{{- end }} {{- end }}
], ],
"articleBody": {{ .Content | safeJS | htmlUnescape | plainify }},
"wordCount" : "{{ .WordCount }}", "wordCount" : "{{ .WordCount }}",
"inLanguage": {{ .Language.Lang | default "en-us" }}, "inLanguage": {{ .Language.Lang | default "en-us" }},
{{ if .Params.cover.image -}} {{ if .Params.cover.image -}}
@ -117,3 +117,4 @@
{{- end }}{{/* .IsPage end */}} {{- end }}{{/* .IsPage end */}}
{{- end -}} {{- end -}}
{{- end -}}