diff options
author | Durand D'souza <durand1@gmail.com> | 2016-10-20 05:12:53 +0300 |
---|---|---|
committer | Durand D'souza <durand1@gmail.com> | 2016-10-20 05:12:53 +0300 |
commit | 97d2b42389149884576b8e86d1cc147eb05676a6 (patch) | |
tree | e880ba192e8cf298f3eb9529517d11149c51821f | |
parent | 508d35ddbd27bb7d72e945a8e3b8b785ebbeff1f (diff) |
Updated twitter and facebook cards
-rw-r--r-- | layouts/partials/head.html | 19 | ||||
-rw-r--r-- | layouts/partials/twitter_og_cards.html | 30 |
2 files changed, 39 insertions, 10 deletions
diff --git a/layouts/partials/head.html b/layouts/partials/head.html index f8da399..1ee1baa 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -7,11 +7,17 @@ <meta charset="utf-8"> <title>{{ if eq .IsHome false }}{{ .Title }} – {{ end }}{{ .Site.Title }}</title> <meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Site.Params.description }}{{ end }}"> +{{ if .IsHome }} + {{ $.Scratch.Set "Params" .Site.Params }} +{{ else if .IsNode }} + {{ $.Scratch.Set "Params" (index .Site.Data.sections (lower .Title)) }} +{{ else }} + {{ $.Scratch.Set "Params" .Params }} +{{ end }} {{ if .Params.tags }}<meta name="keywords" content="{{ delimit .Params.tags ", " }}">{{ end }} -{{ template "_internal/twitter_cards.html" . }} -<!-- Open Graph --> -{{ template "_internal/opengraph.html" . }} +<!-- Open Graph and Twitter cards --> +{{ partial "twitter_og_cards.html" . }} {{ with .Site.Params.google_verify }}<meta name="google-site-verification" content="{{ . }}">{{ end }} {{ with .Site.Params.bing_verify }}<meta name="msvalidate.01" content="{{ . }}">{{ end }} @@ -40,13 +46,6 @@ <!-- Icons --> <link rel="shortcut icon" href="{{ .Site.BaseURL }}/favicon.png"> -{{ if .IsHome }} - {{ $.Scratch.Set "Params" .Site.Params }} -{{ else if .IsNode }} - {{ $.Scratch.Set "Params" (index .Site.Data.sections (lower .Title)) }} -{{ else }} - {{ $.Scratch.Set "Params" .Params }} -{{ end }} {{ with .Params.background }} <style type="text/css">body {background-image:url({{ . | absURL }});}</style> {{ end }} diff --git a/layouts/partials/twitter_og_cards.html b/layouts/partials/twitter_og_cards.html new file mode 100644 index 0000000..735968d --- /dev/null +++ b/layouts/partials/twitter_og_cards.html @@ -0,0 +1,30 @@ +<!-- Twitter Cards --> +<meta name="twitter:title" content="{{ .Title }}"> +{{ with .Description }}<meta name="twitter:description" content="{{ . }}">{{ end }} +{{ with .Site.Params.owner.twitter }}<meta name="twitter:creator" content="{{ . }}">{{ end }} +{{ if isset ($.Scratch.Get "Params") "image" }} + {{ $imageparams := index ($.Scratch.Get "Params") "image" }} + {{ with $imageparams.thumb }} + <meta name="twitter:card" content="summary"> + <meta name="twitter:image" content="{{ . | absURL }}"> + {{ else }} + <meta name="twitter:card" content="summary_large_image"> + <meta name="twitter:image" content="{{ $imageparams.feature | absURL }}"> + {{ end }} +{{ end }} + +<!-- Open Graph --> +<meta property="og:type" content="article"> +<meta property="og:title" content="{{ .Title }}"> +{{ with .Description }}<meta property="og:description" content="{{ . }}">{{ end }} +<meta property="og:url" content="{{ .Permalink }}"> +<meta property="og:site_name" content="{{ .Site.Title }}"> +{{ with .Site.Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }} +{{ if isset ($.Scratch.Get "Params") "image" }} + {{ $imageparams := index ($.Scratch.Get "Params") "image" }} + <meta property="og:image" content="{{ $imageparams.feature | absURL }}" /> +{{ end }} +{{ if not .Date.IsZero }} + <meta property="og:updated_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}"/> +{{ end }} +{{ with .Site.params.author.facebook }}<meta property="article:author" content="https://www.facebook.com/{{ . }}" />{{ end }} |