summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAditya Telange <21258296+adityatelange@users.noreply.github.com>2020-10-11 21:04:17 +0530
committerAditya Telange <21258296+adityatelange@users.noreply.github.com>2020-10-11 21:04:17 +0530
commit4a4d0c009c988e657134253732757b8be4885c7a (patch)
treeea3ab04a0853a721c98b3bbf7a2fbf7c0af343b1
parent6c4e094c91ce143f3895550a28cf0b8057c23e57 (diff)
templates: add cover image to be linked into meta
for opengraph, schema and twitter
-rw-r--r--layouts/partials/templates/opengraph.html7
-rw-r--r--layouts/partials/templates/schema.html7
-rw-r--r--layouts/partials/templates/twitter_cards.html8
3 files changed, 22 insertions, 0 deletions
diff --git a/layouts/partials/templates/opengraph.html b/layouts/partials/templates/opengraph.html
index 07d9775..48ad5eb 100644
--- a/layouts/partials/templates/opengraph.html
+++ b/layouts/partials/templates/opengraph.html
@@ -2,6 +2,13 @@
<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:url" content="{{ .Permalink }}" />
+{{- if .Params.cover.image -}}
+{{- if (ne .Params.cover.relative true) }}
+<meta property="og:image" content="{{ .Params.cover.image | absURL }}" />
+{{- else}}
+<meta property="og:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
+{{- end}}
+{{- end }}
{{ with $.Params.images }}{{ range first 6 . -}}
<meta property="og:image" content="{{ . | absURL }}" />
{{ end }}{{ else -}}
diff --git a/layouts/partials/templates/schema.html b/layouts/partials/templates/schema.html
index 0cbae15..e01dc48 100644
--- a/layouts/partials/templates/schema.html
+++ b/layouts/partials/templates/schema.html
@@ -5,6 +5,13 @@
<meta itemprop="datePublished" {{ .PublishDate.Format $ISO8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
{{ if not .Lastmod.IsZero }}<meta itemprop="dateModified" {{ .Lastmod.Format $ISO8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
<meta itemprop="wordCount" content="{{ .WordCount }}">
+{{- if .Params.cover.image -}}
+{{- if (ne .Params.cover.relative true) }}
+<meta itemprop="image" content="{{ .Params.cover.image | absURL }}" />
+{{- else}}
+<meta itemprop="image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
+{{- end}}
+{{- end }}
{{ with $.Params.images }}{{ range first 6 . -}}
<meta itemprop="image" content="{{ . | absURL }}">
{{ end }}{{ else -}}
diff --git a/layouts/partials/templates/twitter_cards.html b/layouts/partials/templates/twitter_cards.html
index cbe2430..2b3b7c9 100644
--- a/layouts/partials/templates/twitter_cards.html
+++ b/layouts/partials/templates/twitter_cards.html
@@ -1,3 +1,11 @@
+{{- if .Params.cover.image -}}
+<meta name="twitter:card" content="summary_large_image" />
+{{- if (ne $.Params.cover.relative true) }}
+<meta name="twitter:image" content="{{ .Params.cover.image | absURL }}" />
+{{- else }}
+<meta name="twitter:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
+{{- end}}
+{{ end }}
{{- with $.Params.images -}}
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>