Skip to content

Commit 4a4d0c0

Browse files
committed
templates: add cover image to be linked into meta
for opengraph, schema and twitter
1 parent 6c4e094 commit 4a4d0c0

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

layouts/partials/templates/opengraph.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
33
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
44
<meta property="og:url" content="{{ .Permalink }}" />
5+
{{- if .Params.cover.image -}}
6+
{{- if (ne .Params.cover.relative true) }}
7+
<meta property="og:image" content="{{ .Params.cover.image | absURL }}" />
8+
{{- else}}
9+
<meta property="og:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
10+
{{- end}}
11+
{{- end }}
512
{{ with $.Params.images }}{{ range first 6 . -}}
613
<meta property="og:image" content="{{ . | absURL }}" />
714
{{ end }}{{ else -}}

layouts/partials/templates/schema.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
<meta itemprop="datePublished" {{ .PublishDate.Format $ISO8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
66
{{ if not .Lastmod.IsZero }}<meta itemprop="dateModified" {{ .Lastmod.Format $ISO8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
77
<meta itemprop="wordCount" content="{{ .WordCount }}">
8+
{{- if .Params.cover.image -}}
9+
{{- if (ne .Params.cover.relative true) }}
10+
<meta itemprop="image" content="{{ .Params.cover.image | absURL }}" />
11+
{{- else}}
12+
<meta itemprop="image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
13+
{{- end}}
14+
{{- end }}
815
{{ with $.Params.images }}{{ range first 6 . -}}
916
<meta itemprop="image" content="{{ . | absURL }}">
1017
{{ end }}{{ else -}}

layouts/partials/templates/twitter_cards.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
{{- if .Params.cover.image -}}
2+
<meta name="twitter:card" content="summary_large_image" />
3+
{{- if (ne $.Params.cover.relative true) }}
4+
<meta name="twitter:image" content="{{ .Params.cover.image | absURL }}" />
5+
{{- else }}
6+
<meta name="twitter:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
7+
{{- end}}
8+
{{ end }}
19
{{- with $.Params.images -}}
210
<meta name="twitter:card" content="summary_large_image"/>
311
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>

0 commit comments

Comments
 (0)