diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-05-24 22:42:02 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-05-24 22:42:06 +0200 |
| commit | d2f88394bc44e1d0e1d8e9beb72d7055d52ce62e (patch) | |
| tree | 4da42c62f7ce8e0a14f29d214bb0421e773b6597 /layouts/partials/templates | |
| parent | 43c35d217e14fe00a91b2945d4d3bdefe48947b8 (diff) | |
| download | gohugo-theme-ed-d2f88394bc44e1d0e1d8e9beb72d7055d52ce62e.tar.gz | |
Provide ability to use featured image
Diffstat (limited to 'layouts/partials/templates')
| -rw-r--r-- | layouts/partials/templates/opengraph.html | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/layouts/partials/templates/opengraph.html b/layouts/partials/templates/opengraph.html index aed77e3..fbee957 100644 --- a/layouts/partials/templates/opengraph.html +++ b/layouts/partials/templates/opengraph.html @@ -3,26 +3,19 @@ <meta property="og:description" content="{{ (partial "description.html" . ) }}"> <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 }} - {{- if .Params.cover.width -}} - <meta property="og:image:width" content="{{ .Params.cover.width }}"> - {{- end }} +{{- $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) -}} +{{- $image := .Resources.GetMatch .Params.featured_image -}} - {{- if .Params.cover.height -}} - <meta property="og:image:height" content="{{ .Params.cover.height }}"> - {{- end }} +{{- if and .IsPage $image }} + <meta property="og:image" content="{{ $image.Permalink }}"> + <meta property="og:image:width" content="{{ $image.Width }}"> + <meta property="og:image:height" content="{{ $image.Height }}"> {{- else }} - {{- $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) }} <meta property="og:image" content="{{ $logo.Permalink }}"> - <meta property="og:image:width" content="{{ site.Params.assets.logo_width | default 200 }}"> - <meta property="og:image:height" content="{{ site.Params.assets.logo_height | default 200 }}"> -{{- end }} + <meta property="og:image:width" content="{{ $logo.Width }}"> + <meta property="og:image:height" content="{{ $logo.Height }}"> +{{- end -}} {{- /* Facebook Page Admin ID for Domain Insights */}} {{- with site.Social.facebook_admin }} |
