summaryrefslogtreecommitdiffstats
path: root/tpl/tplimpl/embedded/templates/schema.html
blob: 2b3c5425aeb5e7bace28c357c9fd1436177d96cd (plain)
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
{{- with or .Title site.Title | plainify }}
  <meta itemprop="name" content="{{ . }}">
{{- end }}

{{- with or .Description .Summary site.Params.description | plainify | htmlUnescape | chomp }}
  <meta itemprop="description" content="{{ . }}">
{{- end }}

{{- $ISO8601 := "2006-01-02T15:04:05-07:00" }}
{{- with .PublishDate }}
  <meta itemprop="datePublished" {{ .Format $ISO8601 | printf "content=%q" | safeHTMLAttr }}>
{{- end }}

{{- with .Lastmod }}
  <meta itemprop="dateModified" {{ .Format $ISO8601 | printf "content=%q" | safeHTMLAttr }}>
{{- end }}

{{- with .WordCount }}
  <meta itemprop="wordCount" content="{{ . }}">
{{- end }}

{{- $images := partial "_funcs/get-page-images" . }}
{{- range first 6 $images }}
  <meta itemprop="image" content="{{ .Permalink }}">
{{- end }}

{{- /*
Keywords precedence:

1. Use "keywords" term page titles.
2. Use "keywords" from front matter if "keywords" is not a taxonomy.
3. Use "tags" term page titles.
4. Use term page titles from all taxonomies.

*/}}
{{- $keywords := slice }}
{{- range .GetTerms "keywords" }}
  {{- $keywords = $keywords | append .Title }}
{{- else }}
  {{- with .Keywords }}
    {{- $keywords = . }}
  {{- else }}
    {{- range .GetTerms "tags" }}
      {{- $keywords = $keywords | append .Title }}
    {{- else }}
      {{- range $taxonomy, $_ := site.Taxonomies }}
        {{- range $.GetTerms $taxonomy }}
          {{- $keywords = $keywords | append .Title }}
        {{- end }}
      {{- end }}
    {{- end }}
  {{- end }}
{{- end }}
{{- with $keywords }}
  <meta itemprop="keywords" content="{{ delimit . `,` }}">
{{- end -}}