{{ $iso8601 := "2006-01-02T15:04:05-07:00" -}} {{- $isArticle := partial "head/is-article.html" . -}} {{- /* Only raster formats every OG consumer supports; SVG is rejected by all of them. WebP is not dropped but converted: several consumers - LinkedIn among them - do not render it, and skipping it silently costs the page its own image. */ -}} {{- $ogFormats := slice "png" "jpeg" -}} {{- $ogImages := slice -}} {{- range $.Params.images -}} {{- with $.Resources.GetMatch . -}} {{- if in $ogFormats .MediaType.SubType -}} {{- $ogImages = $ogImages | append (.Resize "960x").Permalink -}} {{- else if eq .MediaType.SubType "webp" -}} {{- $ogImages = $ogImages | append (.Resize "960x jpeg q85").Permalink -}} {{- end -}} {{- end -}} {{- end -}} {{- range $.Site.Params.images -}} {{- with resources.GetMatch . -}} {{- if in $ogFormats .MediaType.SubType -}} {{- $ogImages = $ogImages | append (.Resize "960x").Permalink -}} {{- else if eq .MediaType.SubType "webp" -}} {{- $ogImages = $ogImages | append (.Resize "960x jpeg q85").Permalink -}} {{- end -}} {{- end -}} {{- end }} {{ range first 6 $ogImages }} {{- end }} {{- if $isArticle }} {{- /* Only when there is a section to name: a page outside one would emit an empty article:section, which says nothing. */}} {{ with .Section }} {{ end }} {{ with .PublishDate }} {{ end }} {{ with .Lastmod }} {{ end }} {{- end -}} {{- with .Params.audio }} {{ end }} {{- /* Falls back to the page's own language. Open Graph wants the underscore form (pt_PT), while Hugo reports the locale with a hyphen. */ -}} {{- with .Params.locale | default (replace (.Language.Locale | default .Site.Language.Lang) "-" "_") }} {{ end }} {{- with .Site.Title }} {{ end }} {{- with .Params.videos }} {{- range . }} {{ end }} {{ end }} {{- /* If it is part of a series, link to related articles */}} {{- $permalink := .Permalink }} {{- range .GetTerms "series" }} {{- range first 6 .Pages }} {{- if ne .Permalink $permalink }} {{- end }} {{- end }} {{- end }}