|
1 | | -{{/* From https://github.com/gohugoio/gohugoioTheme/blob/master/layouts/partials/opengraph/opengraph.html */}} |
| 1 | +{{/* Adapted from https://github.com/gohugoio/hugo/blob/v0.149.0/docs/layouts/_partials/opengraph/opengraph.html */}} |
2 | 2 |
|
3 | | -<meta property="og:title" content="{{ .Title }}" /> |
4 | | -<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" /> |
5 | | -<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" /> |
6 | | -<meta property="og:url" content="{{ .Permalink }}" /> |
| 3 | +<meta property="og:title" content="{{ .Title }}"> |
| 4 | +<meta |
| 5 | + property="og:description" |
| 6 | + content="{{ with .Description }} |
| 7 | + {{ . }} |
| 8 | + {{ else }} |
| 9 | + {{ if .IsPage }} |
| 10 | + {{ .Summary }} |
| 11 | + {{ else }} |
| 12 | + {{ with .Site.Params.description }}{{ . }}{{ end }} |
| 13 | + {{ end }} |
| 14 | + {{ end }}"> |
| 15 | +<meta |
| 16 | + property="og:type" |
| 17 | + content="{{ if .IsPage }} |
| 18 | + article |
| 19 | + {{ else }} |
| 20 | + website |
| 21 | + {{ end }}"> |
| 22 | +<meta property="og:url" content="{{ .Permalink }}"> |
7 | 23 |
|
8 | 24 | {{- with $.Params.images -}} |
9 | | -{{- range first 6 . }}<meta property="og:image" content="{{ . | absURL }}" />{{ end -}} |
| 25 | +{{- range first 6 . }} |
| 26 | +<meta property="og:image" content="{{ . | absURL }}"> |
| 27 | +{{ end -}} |
10 | 28 | {{- else -}} |
11 | 29 | {{- $featured := "" }} |
12 | 30 | {{- with $featured -}} |
13 | | -<meta property="og:image" content="{{ $featured.Permalink }}"/> |
| 31 | +<meta property="og:image" content="{{ $featured.Permalink }}"> |
14 | 32 | {{- else -}} |
15 | | -{{- with $.Site.Params.images }}<meta property="og:image" content="{{ index . 0 | absURL }}"/>{{ end -}} |
| 33 | +{{- with $.Site.Params.images }} |
| 34 | +<meta property="og:image" content="{{ index . 0 | absURL }}"> |
| 35 | +{{ end -}} |
16 | 36 | {{- end -}} |
17 | 37 | {{- end -}} |
18 | 38 |
|
19 | 39 | {{- if .IsPage }} |
20 | 40 | {{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} |
21 | | -<meta property="article:section" content="{{ .Section }}" /> |
22 | | -{{ with .PublishDate }}<meta property="article:published_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }} |
23 | | -{{ with .Lastmod }}<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }} |
| 41 | +<meta property="article:section" content="{{ .Section }}"> |
| 42 | +{{ with .PublishDate }} |
| 43 | +<meta |
| 44 | + property="article:published_time" |
| 45 | + {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}> |
| 46 | +{{ end }} |
| 47 | +{{ with .Lastmod }} |
| 48 | +<meta |
| 49 | + property="article:modified_time" |
| 50 | + {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}> |
| 51 | +{{ end }} |
24 | 52 | {{- end -}} |
25 | 53 |
|
26 | | -{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }} |
27 | | -{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }} |
28 | | -{{- with .Site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }} |
29 | | -{{- with .Params.videos }}{{- range . }} |
30 | | -<meta property="og:video" content="{{ . | absURL }}" /> |
31 | | -{{ end }}{{ end }} |
| 54 | +{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}">{{ end }} |
| 55 | +{{- with .Params.locale }} |
| 56 | +<meta property="og:locale" content="{{ . }}"> |
| 57 | +{{ end }} |
| 58 | +{{- with .Site.Params.title }} |
| 59 | +<meta property="og:site_name" content="{{ . }}"> |
| 60 | +{{ end }} |
| 61 | +{{- with .Params.videos }} |
| 62 | +{{- range . }} |
| 63 | +<meta property="og:video" content="{{ . | absURL }}"> |
| 64 | +{{ end }} |
| 65 | + |
| 66 | +{{ end }} |
| 67 | + |
| 68 | +{{- /* If it is part of a series, link to related articles */}} |
| 69 | +{{- $permalink := .Permalink }} |
| 70 | +{{- $siteSeries := .Site.Taxonomies.series }} |
| 71 | +{{ with .Params.series }} |
| 72 | +{{- range $name := . }} |
| 73 | +{{- $series := index $siteSeries ($name | urlize) }} |
| 74 | +{{- range $page := first 6 $series.Pages }} |
| 75 | +{{- if ne $page.Permalink $permalink }} |
| 76 | +<meta property="og:see_also" content="{{ $page.Permalink }}"> |
| 77 | +{{ end }} |
| 78 | +{{- end }} |
| 79 | +{{ end }} |
| 80 | + |
| 81 | +{{ end }} |
| 82 | + |
| 83 | +{{- /* Facebook Page Admin ID for Domain Insights */}} |
| 84 | +{{- with site.Params.social.facebook_admin }} |
| 85 | +<meta property="fb:admins" content="{{ . }}"> |
| 86 | +{{ end }} |
0 commit comments