|
| 1 | +{{- $params := .Scratch.Get "params" -}} |
| 2 | + |
| 3 | +{{- with .Site.Params.verification.google -}} |
| 4 | + <meta name="google-site-verification" content="{{ . }}" /> |
| 5 | +{{- end -}} |
| 6 | +{{- with .Site.Params.verification.bing -}} |
| 7 | + <meta name="msvalidate.01" content="{{ . }}" /> |
| 8 | +{{- end -}} |
| 9 | +{{- with .Site.Params.verification.yandex -}} |
| 10 | + <meta name="yandex-verification" content="{{ . }}" /> |
| 11 | +{{- end -}} |
| 12 | +{{- with .Site.Params.verification.pinterest -}} |
| 13 | + <meta name="p:domain_verify" content="{{ . }}" /> |
| 14 | +{{- end -}} |
| 15 | +{{- with .Site.Params.verification.baidu -}} |
| 16 | + <meta name="baidu-site-verification" content="{{ . }}" /> |
| 17 | +{{- end -}} |
| 18 | + |
| 19 | +{{- /* Home SEO */ -}} |
| 20 | +{{- if .IsHome -}} |
| 21 | + <script type="application/ld+json"> |
| 22 | + { |
| 23 | + "@context": "http://schema.org", |
| 24 | + "@type": "WebSite", |
| 25 | + "url": "{{ .Permalink }}", |
| 26 | + {{- with .Site.LanguageCode -}} |
| 27 | + "inLanguage": "{{ . }}", |
| 28 | + {{- end -}} |
| 29 | + {{- with .Site.Params.author.name -}} |
| 30 | + "author": { |
| 31 | + "@type": "Person", |
| 32 | + "name": {{ . | safeHTML }} |
| 33 | + }, |
| 34 | + {{- end -}} |
| 35 | + {{- with .Site.Params.description -}} |
| 36 | + "description": {{ . | safeHTML }}, |
| 37 | + {{- end -}} |
| 38 | + {{- $image := .Site.Params.seo.image -}} |
| 39 | + {{- with dict "Path" $image "Resources" .Resources | partial "function/resource.html" -}} |
| 40 | + "image": { |
| 41 | + "@type": "ImageObject", |
| 42 | + "url": "{{ .Permalink }}", |
| 43 | + "width": {{ .Width }}, |
| 44 | + "height": {{ .Height }} |
| 45 | + }, |
| 46 | + {{- else -}} |
| 47 | + {{- with $image -}} |
| 48 | + "image": "{{ . | absURL }}", |
| 49 | + {{- end -}} |
| 50 | + {{- end -}} |
| 51 | + {{- with .Site.Params.seo.thumbnailUrl -}} |
| 52 | + {{- with dict "Path" . "Resources" $.Resources | partial "function/resource.html" -}} |
| 53 | + "thumbnailUrl": "{{ .Permalink }}", |
| 54 | + {{- else -}} |
| 55 | + "thumbnailUrl": "{{ . | absURL }}", |
| 56 | + {{- end -}} |
| 57 | + {{- end -}} |
| 58 | + {{- with .Site.Copyright -}} |
| 59 | + "license": "{{ . | safeHTML }}", |
| 60 | + {{- end -}} |
| 61 | + "name": {{ .Site.Title | safeHTML }} |
| 62 | + } |
| 63 | + </script> |
| 64 | + |
| 65 | +{{- /* Page SEO */ -}} |
| 66 | +{{- else if .IsPage -}} |
| 67 | + <script type="application/ld+json"> |
| 68 | + { |
| 69 | + "@context": "http://schema.org", |
| 70 | + "@type": "BlogPosting", |
| 71 | + "headline": {{ .Title | safeHTML }}, |
| 72 | + "inLanguage": "{{ .Site.LanguageCode }}", |
| 73 | + "mainEntityOfPage": { |
| 74 | + "@type": "WebPage", |
| 75 | + "@id": "{{ .Permalink }}" |
| 76 | + }, |
| 77 | + {{- $images := $params.seo.images | default slice -}} |
| 78 | + {{- if not $images -}} |
| 79 | + {{- with .Resources.GetMatch "featured-image-preview" -}} |
| 80 | + {{- $images = slice "featured-image-preview" -}} |
| 81 | + {{- end -}} |
| 82 | + {{- with .Resources.GetMatch "featured-image" -}} |
| 83 | + {{- $images = slice "featured-image" -}} |
| 84 | + {{- end -}} |
| 85 | + {{- end -}} |
| 86 | + {{- with .Site.Params.seo.image -}} |
| 87 | + {{- $images = $images | default (slice .) -}} |
| 88 | + {{- end -}} |
| 89 | + {{- with $images -}} |
| 90 | + "image": [ |
| 91 | + {{- range $index, $value := . -}} |
| 92 | + {{- if gt $index 0 }},{{ end -}} |
| 93 | + {{- with dict "Path" $value "Resources" $.Resources | partial "function/resource.html" -}} |
| 94 | + { |
| 95 | + "@type": "ImageObject", |
| 96 | + "url": "{{ .Permalink }}", |
| 97 | + "width": {{ .Width }}, |
| 98 | + "height": {{ .Height }} |
| 99 | + } |
| 100 | + {{- else -}} |
| 101 | + {{- with $value -}} |
| 102 | + "{{ . | absURL }}" |
| 103 | + {{- end -}} |
| 104 | + {{- end -}} |
| 105 | + {{- end -}} |
| 106 | + ], |
| 107 | + {{- end -}} |
| 108 | + "genre": "{{ .Type }}", |
| 109 | + {{- with .Params.tags -}} |
| 110 | + "keywords": "{{ delimit . ", " }}", |
| 111 | + {{- end -}} |
| 112 | + "wordcount": {{ .WordCount }}, |
| 113 | + "url": "{{ .Permalink }}", |
| 114 | + {{- if not .PublishDate.IsZero -}} |
| 115 | + "datePublished": {{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTML }}, |
| 116 | + {{- else if not .Date.IsZero -}} |
| 117 | + "datePublished": {{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}, |
| 118 | + {{- end -}} |
| 119 | + {{- with .Lastmod -}} |
| 120 | + "dateModified": {{ .Format "2006-01-02T15:04:05-07:00" | safeHTML }}, |
| 121 | + {{- end -}} |
| 122 | + {{- with .Site.Copyright -}} |
| 123 | + "license": {{ . | safeHTML }}, |
| 124 | + {{- end -}} |
| 125 | + {{- $publisher := .Params.author | default .Site.Params.author.name | default (T "author") | dict "name" -}} |
| 126 | + {{- $publisher = $params.seo.publisher | default dict | merge $publisher -}} |
| 127 | + "publisher": { |
| 128 | + "@type": "Organization", |
| 129 | + "name": {{ $publisher.name | safeHTML }} |
| 130 | + {{- $logo := $publisher.logoUrl -}} |
| 131 | + {{- with dict "Path" $logo "Resources" .Resources | partial "function/resource.html" -}} |
| 132 | + ,"logo": { |
| 133 | + "@type": "ImageObject", |
| 134 | + "url": "{{ .Permalink }}", |
| 135 | + "width": {{ .Width }}, |
| 136 | + "height": {{ .Height }} |
| 137 | + } |
| 138 | + {{- else -}} |
| 139 | + {{- with $logo -}} |
| 140 | + ,"logo": "{{ . | absURL }}" |
| 141 | + {{- end -}} |
| 142 | + {{- end -}} |
| 143 | + }, |
| 144 | + {{- with .Params.author | default .Site.Params.author.name | default (T "author") -}} |
| 145 | + "author": { |
| 146 | + "@type": "Person", |
| 147 | + "name": {{ . | safeHTML }} |
| 148 | + }, |
| 149 | + {{- end -}} |
| 150 | + "description": {{ .Description | safeHTML }} |
| 151 | + } |
| 152 | + </script> |
| 153 | +{{- end -}} |
0 commit comments