Files
markusgraf_ch/layouts/partials/opengraph.html
T

33 lines
1.4 KiB
HTML

{{/* Open Graph / Social Media Meta Tags */}}
{{/* Basic OG tags */}}
<meta property="og:title" content="{{ .Title }}">
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}">
<meta property="og:site_name" content="{{ .Site.Title }}">
<meta property="og:locale" content="{{ .Language.Lang }}">
{{/* Article-specific tags */}}
{{ if .IsPage }}
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
{{ with .Lastmod }}<meta property="article:modified_time" content="{{ .Format "2006-01-02T15:04:05Z07:00" }}">{{ end }}
{{ end }}
{{/* Image handling: only render if images defined in frontmatter */}}
{{ with .Params.images }}
{{ range first 1 . }}
{{ $img := . }}
{{ if not (hasPrefix $img "http") }}
{{ $img = printf "%s%s" $.Permalink $img }}
{{ end }}
<meta property="og:image" content="{{ $img }}">
<meta name="twitter:image" content="{{ $img }}">
{{ end }}
{{ end }}
{{/* Twitter Card */}}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="{{ .Title }}">
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}">