1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
{{ $baseURL := "/" | absURL -}}
{{ $dot := . -}}
{{ $dot.Scratch.Set "path" "" -}}
{{ $dot.Scratch.Set "breadcrumb" slice -}}
{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" -}}
{{ $.Scratch.Add "path" .Site.BaseURL -}}
{{ $.Scratch.Add "breadcrumb" (slice (dict "url" .Site.BaseURL "name" "home" "position" 1 )) -}}
{{ range $index, $element := split $url "/" -}}
{{ $dot.Scratch.Add "path" $element -}}
{{ $.Scratch.Add "path" "/" -}}
{{ if ne $element "" -}}
{{ $.Scratch.Add "breadcrumb" (slice (dict "url" ($.Scratch.Get "path") "name" . "position" (add $index 2))) -}}
{{ end -}}
{{ end -}}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
{{ if eq .Site.Params.schemaType "Organization" -}}
"@type": "Organization",
"@id": {{ print $baseURL "#/schema/organization/1" }},
{{ else -}}
"@type": "Person",
"@id": {{ print $baseURL "#/schema/person/1" }},
{{ end -}}
"name": "{{ .Site.Params.schemaName }}",
"url": {{ print $baseURL }},
"sameAs": [
{{ with .Site.Params.schemaTwitter -}}
{{ . }}
{{ end -}}
{{ with .Site.Params.schemaLinkedIn -}}
, {{ . }}
{{ end -}}
{{ with .Site.Params.schemaGitHub -}}
, {{ . }}
{{ end -}}
],
{{ if eq .Site.Params.schemaType "Organization" -}}
"logo": {
"@type": "ImageObject",
"@id": {{ print $baseURL "#/schema/image/1"}},
"url": {{ print $baseURL .Site.Params.schemaLogo }},
"width": {{ .Site.Params.schemaLogoWidth }},
"height": {{ .Site.Params.schemaLogoHeight }},
"caption": "{{ .Site.Params.schemaName }}"
},
"image": {
"@id": {{ print $baseURL "#/schema/image/1" }}
}
{{ else -}}
"image": {
"@type": "ImageObject",
"@id": {{ print $baseURL "#/schema/image/1"}},
"url": {{ print $baseURL .Site.Params.schemaImage }},
"width": {{ .Site.Params.schemaImageWidth }},
"height": {{ .Site.Params.schemaImageHeight }},
"caption": "{{ .Site.Params.schemaName }}"
}
{{ end -}}
},
{
"@type": "WebSite",
"@id": {{ print $baseURL "#/schema/website/1" }},
"url": {{ print $baseURL }},
"name": "{{ .Site.Params.title }}",
"description": "{{ .Site.Params.description }}",
{{ if eq .Site.Params.schemaType "Organization" -}}
"publisher": {
"@id": {{ print $baseURL "#/schema/organization/1" }}
}
{{ else -}}
"publisher": {
"@id": {{ print $baseURL "#/schema/person/1" }}
}
{{ end -}}
},
{
{{ if and (ne .Kind "taxonomy") (ne .Kind "term") -}}
"@type": "WebPage",
{{ else -}}
"@type": "CollectionPage",
{{ end -}}
"@id": {{ .Permalink }},
"url": {{ .Permalink }},
"name": "{{ .Title }}",
"description": "{{ .Description }}",
"isPartOf": {
"@id": {{ print $baseURL "#/schema/website/1" }}
},
{{ if eq .Site.Params.schemaType "Organization" -}}
"about": {
"@id": {{ print $baseURL "#/schema/organization/1" }}
},
{{ else -}}
"about": {
"@id": {{ print $baseURL "#/schema/person/1" }}
},
{{ end -}}
"datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05CET" }}",
"dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05CET" }}",
"breadcrumb": {
"@id": {{ print .Permalink "#/schema/breadcrumb/1" }}
},
"primaryImageOfPage": {
"@id": {{ print .Permalink "#/schema/image/2" }}
},
"inLanguage": "{{ .Site.Params.schemaLocale }}",
"potentialAction": [{
"@type": "ReadAction", "target": [{{ .Permalink }}]
}]
},
{
"@type": "BreadcrumbList",
"@id": {{ print .Permalink "#/schema/breadcrumb/1" }},
"name": "Breadcrumbs",
"itemListElement": [{{ $list := $.Scratch.Get "breadcrumb" }}{{ $len := (len $list) }}{{ range $index, $element := $list }}{{ if ne .position 1 }},{{ end }}{
"@type": "ListItem",
"position": {{ .position }},
"item": {
{{ if ne (add $index 1) $len -}}
"@type": "WebPage",
"@id": {{ .url }},
"url": {{ .url }},
"name": "{{ .name | humanize | title }}"
{{ else -}}
"@id": {{ .url }}
{{ end -}}
}
}{{ end }}]
},
{{ if and (eq .Kind "page") (or (eq .Section "blog") (eq .Section "docs") (eq .Section "tutorial") (eq .Section "showcase")) -}}
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "Article",
"@id": {{ print $baseURL "#/schema/article/1" }},
"headline": "{{ .Title }}",
"description": "{{ .Description }}",
"isPartOf": {
"@id": {{ .Permalink }}
},
"mainEntityOfPage": {
"@id": {{ .Permalink }}
},
"datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05CET" }}",
"dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05CET" }}",
"author": {
"@id": {{ print $baseURL "#/schema/person/2" }}
},
{{ if eq .Site.Params.schemaType "Organization" -}}
"publisher": {
"@id": {{ print $baseURL "#/schema/organization/1" }}
},
{{ else -}}
"publisher": {
"@id": {{ print $baseURL "#/schema/person/1" }}
},
{{ end -}}
"image": {
"@id": {{ print .Permalink "#/schema/image/2" }}
}
}
]
},
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "Person",
"@id": {{ print $baseURL "#/schema/person/2" }},
"name": {{ .Site.Params.schemaAuthor }},
"sameAs": [
{{ with .Site.Params.schemaAuthorTwitter -}}
{{ . }}
{{ end -}}
{{ with .Site.Params.schemaAuthorLinkedIn -}}
, {{ . }}
{{ end -}}
{{ with .Site.Params.schemaAuthorGitHub -}}
, {{ . }}
{{ end -}}
]
}
]
},
{{ end -}}
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "ImageObject",
"@id": {{ print .Permalink "#/schema/image/2" }},
"url": {{ $.Scratch.Get "primaryImage" }},
"contentUrl": {{ $.Scratch.Get "primaryImage" }},
"caption": "{{ .Title }}"
}
]
}
]
}
</script>
|