diff options
author | Marcin Mierzejewski <marcin@mierzejewski.net> | 2020-05-03 14:51:54 +0300 |
---|---|---|
committer | Marcin Mierzejewski <marcin@mierzejewski.net> | 2020-05-03 14:51:54 +0300 |
commit | 3184aed8b5f065557c3dccb6fe9dcbf3afdf42cf (patch) | |
tree | 508b21ad543367819db03921548f32b2ff066b37 | |
parent | 512902121b2c48231bbbc9dfbe49c21f768a579c (diff) |
twitter: add twitter cards
-rw-r--r-- | layouts/_default/baseof.html | 2 | ||||
-rw-r--r-- | layouts/partials/twitter_cards.html | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 0fa4cc4..2c71714 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -23,7 +23,7 @@ {{ printf `<link href="%s" rel="%s" type="%s" title="%s" />` .Permalink .Rel .MediaType.Type $.Site.Title | safeHTML }} {{ end }} {{- partial "opengraph.html" . -}} - {{ template "_internal/twitter_cards.html" . }} + {{- partial "twitter_cards.html" . -}} {{ template "_internal/google_analytics.html" . }} </head> <body class="terminal"> diff --git a/layouts/partials/twitter_cards.html b/layouts/partials/twitter_cards.html new file mode 100644 index 0000000..cac9672 --- /dev/null +++ b/layouts/partials/twitter_cards.html @@ -0,0 +1,19 @@ +{{- with .Params.image }} +{{ $image := $.Resources.GetMatch . }} +{{ with $image }} +{{ $thumb := .Resize "400x" }} +<meta name="twitter:card" content="summary_large_image"/> +<meta name="twitter:image" content="{{ $thumb.Permalink }}"> +{{ end }} +{{ end }} + +<meta name="twitter:title" content="{{ .Title }}"/> +<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/> +{{ with .Site.Social.twitter -}} +<meta name="twitter:site" content="@{{ . }}"/> +{{ end -}} +{{ range .Site.Authors }} +{{ with .twitter -}} +<meta name="twitter:creator" content="@{{ . }}"/> +{{ end -}} +{{ end -}}
\ No newline at end of file |