diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-07-17 23:08:59 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-07-17 23:09:52 +0200 |
commit | 00b590d7ab4f3021814acceaf74c4eaf64edb226 (patch) | |
tree | 07753ae64fa11ea9ac2e0396e428997fb2cde49d /tpl | |
parent | ea5e9e346c93320538c6517b619b5f57473291c8 (diff) |
Improve the twitter card template
Now fall back to `images` set in site config for twitter card.
Fixes #3711
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/tplimpl/template_embedded.go | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/tpl/tplimpl/template_embedded.go b/tpl/tplimpl/template_embedded.go index 4c7113ae3..14f9f138c 100644 --- a/tpl/tplimpl/template_embedded.go +++ b/tpl/tplimpl/template_embedded.go @@ -231,23 +231,22 @@ func (t *templateHandler) embedTemplates() { <!-- Facebook Page Admin ID for Domain Insights --> {{ with .Site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}`) - t.addInternalTemplate("", "twitter_cards.html", `{{ if .IsPage }} -{{ with .Params.images }} -<!-- Twitter summary card with large image must be at least 280x150px --> - <meta name="twitter:card" content="summary_large_image"/> - <meta name="twitter:image:src" content="{{ index . 0 | absURL }}"/> -{{ else }} - <meta name="twitter:card" content="summary"/> -{{ end }} - -<!-- Twitter Card data --> -<meta name="twitter:text:title" content="{{ .Title }}"/> + t.addInternalTemplate("", "twitter_cards.html", `{{- with $.Param "images" -}} +<meta name="twitter:card" content="summary_large_image"/> +<meta name="twitter:image:src" content="{{ index . 0 | absURL }}"/> +{{ else -}} +<meta name="twitter:card" content="summary"/> +{{- 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 }} +<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 }}{{ end }}`) +{{ with .twitter -}} +<meta name="twitter:creator" content="@{{ . }}"/> +{{ end -}} +{{ end -}}`) t.addInternalTemplate("", "google_news.html", `{{ if .IsPage }}{{ with .Params.news_keywords }} <meta name="news_keywords" content="{{ range $i, $kw := first 10 . }}{{ if $i }},{{ end }}{{ $kw }}{{ end }}" /> |