opengraph.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. {{ $isPage := or (and (ne .Type "posts") (in "section page" .Kind )) (and (eq .Type "posts") (eq .Kind "page")) }}
  2. {{- if ne .Kind "home" }}
  3. <meta
  4. property="og:title"
  5. {{ partial "utils/title" . | printf "content=%q" | safeHTMLAttr }}
  6. />
  7. {{- end }}
  8. {{- with .Site.Title }}
  9. <meta property="og:site_name" {{ . | printf "content=%q" | safeHTMLAttr }} />
  10. {{- end }}
  11. {{- with partial "utils/featured" . }}
  12. <meta property="og:image" content="{{ . }}" />
  13. {{- end }}
  14. {{- with partial "utils/description" . }}
  15. <meta property="og:description" content="{{ . | plainify | htmlUnescape | chomp }}" />
  16. {{- end }}
  17. <meta property="og:type" content="{{ if $isPage }}article{{ else }}website{{ end }}" />
  18. <meta property="og:url" content="{{ .Permalink }}" />
  19. {{- with .Params.audio }}
  20. <meta property="og:audio" content="{{ . }}" />
  21. {{- end }}
  22. {{- with .Params.locale }}
  23. <meta property="og:locale" content="{{ . }}" />
  24. {{- end }}
  25. {{- with .Params.videos }}
  26. {{- range . }}
  27. <meta property="og:video" content="{{ . | absURL }}" />
  28. {{- end }}
  29. {{- end }}
  30. {{- /* If it is part of a series, link to related articles */}}
  31. {{- if .Site.Taxonomies.series }}
  32. {{- $permalink := .Permalink -}}
  33. {{- $siteSeries := .Site.Taxonomies.series -}}
  34. {{- with .Params.series }}
  35. {{- range $name := . }}
  36. {{- $series := index $siteSeries ($name | urlize) }}
  37. {{- range $page := first 6 $series.Pages }}
  38. {{- if ne $page.Permalink $permalink }}
  39. <meta property="og:see_also" content="{{ $page.Permalink }}" />
  40. {{- end }}
  41. {{- end }}
  42. {{- end }}
  43. {{- end }}
  44. {{- end }}
  45. {{ if $isPage -}}
  46. {{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
  47. <meta property="article:section" content="{{ .Section | humanize | title }}" />
  48. {{- with .PublishDate }}
  49. <meta
  50. property="article:published_time"
  51. {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}
  52. />
  53. {{- end }}
  54. {{- with .Lastmod }}
  55. <meta
  56. property="article:modified_time"
  57. {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}
  58. />
  59. {{- end }}
  60. {{- end }}
  61. {{- /* Facebook Page Admin ID for Domain Insights */}}
  62. {{- with .Site.Params.facebook_admin }}
  63. <meta property="fb:admins" content="{{ . }}" />
  64. {{- end }}