diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 3ca809de..07b9dd1f 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -54,24 +54,28 @@ {{/* Social */}} {{ template "_internal/opengraph.html" . }} {{ template "_internal/twitter_cards.html" . }} - - {{/* Main page always uses this; fallback elsewhere if no feature image */}} - {{/* See https://gohugo.io/templates/embedded/#open-graph */}} - {{ $images := .Resources.ByType "image" }} - {{ $socialImage := $images.GetMatch "*feature*" }} - {{ if not $socialImage }} + {{/* Use defaultSocialImage if feature image does not exist */}} + {{ $featureImage := "" }} + {{ $pageImages := .Resources.ByType "image" }} + {{ range slice "*featured*" "*cover*" "*thumbnail*" }} + {{ if not $featureImage }} + {{ $featureImage = $pageImages.GetMatch . }} + {{ end }} + {{ end }} + {{ if not $featureImage }} {{ with .Site.Params.defaultSocialImage }} + {{ $socialImage := "" }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} {{ $socialImage = resources.GetRemote . }} {{ else }} {{ $socialImage = resources.Get . }} {{ end }} + {{ with $socialImage }} + + + {{ end }} {{ end }} {{ end }} - {{ with $socialImage }} - - - {{ end }} {{/* Site Verification */}} {{ with .Site.Params.verification.google }}