diff options
1 files changed, 71 insertions, 0 deletions
| -rw-r--r-- | layouts/partials/opengraph.html | 71 |
diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html new file mode 100644 index 0000000..29332fd --- /dev/null +++ b/layouts/partials/opengraph.html @@ -0,0 +1,71 @@ +{{- $summary := .Summary | truncate 160 }} +{{- with .Params.description }} + {{- $summary = (. | truncate 160) }} +{{- end }} +{{- $site := .Site.Title }} +{{- $title := .Title }} +{{- $params := .Site.Params }} +{{- $permalink := .Permalink }} +{{- $logo := absURL $params.logo }} +{{- $author := $params.author }} +{{- with .Params.author }} + {{ $author := . }} +{{- end }} +{{- $image := absURL $params.fallBackOgImage }} +{{- with .Params.featureImage }} + {{- $image = absURL . }} +{{- end }} +{{- with .Params.thumbnail }} + {{- $image = absURL . }} +{{- end }} +{{- with .Params.shareImage }} + {{- $image = absURL . }} +{{- 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 name="description" content="{{ $summary }}"> +<meta name = "twitter:card" content = "{{ if $params.largeTwitterCard }}summary_large_image{{ else }}summary{{ end }}" /> +<meta name = "twitter:creator" content = "{{ $params.twitter }}"> +<meta name = "twitter:title" content = "{{ .Title }}" /> +<meta property = "og:url" content = "{{ $permalink }}" /> +<meta property = "og:title" content = "{{ $title }}" /> +<meta property = "og:description" content = "{{ $summary }}" /> +<meta property = "og:image" content = "{{ $image }}" /> +{{- if eq .Section $params.blogDir -}} + {{- $date := ( .Date.Format "2006-02-01") -}} + {{- $date := (time .Date) }} + {{- $lastMod := (time .Lastmod) }} + <script type = "application/ld+json"> + { + "@context": "http://schema.org", + "@type": "BlogPosting", + "mainEntityOfPage":"{{ $permalink }}", + "name": "{{ $site }}", + "headline": {{ $title }}, + "description": {{ $summary }}, + "url": "{{ $permalink }}", + "datePublished": {{ $date }}, + "dateModified": {{ $lastMod }}, + "author": { + "@type": "Person", + "name": "{{ $author }}" + }, + "image":{ + "@type":"ImageObject", + "url": "{{ $image }}" + }, + "publisher": { + "@type": "Organization", + "logo": { + "@type":"ImageObject", + "url": "{{ $logo }}" + }, + "name": "{{ $site }}" + } + } + </script> +{{- end }} |
