summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei Iakovlev <egrep@protonmail.ch>2022-05-27 00:06:52 +0200
committerSerghei Iakovlev <egrep@protonmail.ch>2022-05-27 00:06:52 +0200
commitf359fa5d8c38e6b2f28d8c0395c170a2a1c936d7 (patch)
treec8643ce0f164f5b3dbcfabfb5bf9092f8188f388
parent649d3c4bd982876ce358c7ff4e4b7aca05f5109a (diff)
downloadgohugo-theme-ed-f359fa5d8c38e6b2f28d8c0395c170a2a1c936d7.tar.gz
Check for featured image
-rw-r--r--layouts/partials/templates/opengraph.html6
-rw-r--r--layouts/partials/templates/twitter_cards.html6
2 files changed, 10 insertions, 2 deletions
diff --git a/layouts/partials/templates/opengraph.html b/layouts/partials/templates/opengraph.html
index c65cdac..5b81f94 100644
--- a/layouts/partials/templates/opengraph.html
+++ b/layouts/partials/templates/opengraph.html
@@ -5,7 +5,11 @@
<meta property="og:url" content="{{ .Permalink }}">
{{- $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) -}}
-{{- $image := .Resources.GetMatch .Params.featured_image -}}
+
+{{- $image := "" -}}
+{{- with .Params.featured_image -}}
+ {{- $image := .Resources.GetMatch .Params.featured_image -}}
+{{- end -}}
{{- if and .IsPage $image }}
<meta property="og:image" content="{{ $image.Permalink }}">
diff --git a/layouts/partials/templates/twitter_cards.html b/layouts/partials/templates/twitter_cards.html
index 970c137..f271f5f 100644
--- a/layouts/partials/templates/twitter_cards.html
+++ b/layouts/partials/templates/twitter_cards.html
@@ -8,7 +8,11 @@
{{- end }}
{{- $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) -}}
- {{- $image := .Resources.GetMatch .Params.featured_image -}}
+
+ {{- $image := "" -}}
+ {{- with .Params.featured_image -}}
+ {{- $image := .Resources.GetMatch .Params.featured_image -}}
+ {{- end -}}
{{- if and .IsPage $image }}
<meta name="twitter:card" content="summary_large_image">