mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 16:31:52 +01:00
fix(head): social image meta duplication
This commit is contained in:
@@ -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 }}
|
||||
<meta name="twitter:image" content="{{ .RelPermalink | absURL }}">
|
||||
<meta property="og:image" content="{{ .RelPermalink | absURL }}">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with $socialImage }}
|
||||
<meta name="twitter:image" content="{{ .RelPermalink | absURL }}">
|
||||
<meta property="og:image" content="{{ .RelPermalink | absURL }}">
|
||||
{{ end }}
|
||||
|
||||
{{/* Site Verification */}}
|
||||
{{ with .Site.Params.verification.google }}
|
||||
|
||||
Reference in New Issue
Block a user