redzuurdesem/themes/desem-swift-theme/layouts/partials/opengraph.html

35 lines
1.3 KiB
HTML

{{- $summary := .Summary | truncate 160 }}
{{- with .Params.description }}
{{- $summary = (. | truncate 160) }}
{{- end }}
{{- $site := .Site.Title }}
{{- $title := .Title }}
{{- $params := .Site.Params }}
{{- $permalink := .Permalink }}
{{- $logo := absURL (printf "images/%s" $params.logo) }}
{{- $image := absURL (printf "images/%s" $params.image) }}
{{- $author := $params.author }}
{{- with .Params.author }}
{{ $author := . }}
{{- end }}
{{- with .Params.image }}
{{- $image = absURL (printf "images/%s" .) }}
{{- end }}
<meta property = 'og:locale' content = 'en_US' />
{{- if .IsHome }}
<meta property="og:type" content="website">
{{- else }}
<meta property="og:type" content="article">
{{- end }}
<meta property = 'og:title' content = '{{ $title }}' />
<meta name="description" content="{{ $title}} {{ $summary }}">
<meta property = 'og:description' content = '{{ $title }} {{ $summary }}'>
<meta property = 'og:url' content = '{{ $permalink }}' />
<meta property = 'og:image' content = '{{ $image }}'/>
<meta name = 'twitter:card' content = 'summary_large_image' />
<meta name = 'twitter:creator' content = '{{ $params.twitter }}'>
<meta name = 'twitter:title' content = '{{ .Title }}' />
<meta property = 'twitter:description' content = '{{ $summary }}'/>
<meta name = 'twitter:image' content = '{{ $image }}' />