diff options
author | koirand <koirand.jp@gmail.com> | 2020-02-26 14:01:30 +0300 |
---|---|---|
committer | koirand <koirand.jp@gmail.com> | 2020-02-26 14:01:30 +0300 |
commit | fa8ad522cc1cb523c72530248d6fdb1da41a0c79 (patch) | |
tree | 581be601b3fe3c19bd25ad98ea9468ff4d083d89 | |
parent | e628e67fd1e31144c7958daa15b5c4e13f935988 (diff) | |
parent | 5ec3ca7120c3a78a09359ea5b6d2b00d7e9b8c17 (diff) |
merge branch into master
-rw-r--r-- | layouts/partials/head.html | 3 | ||||
-rw-r--r-- | layouts/partials/twitter_cards.html | 31 |
2 files changed, 33 insertions, 1 deletions
diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 9df31f8..b4c383d 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -29,7 +29,8 @@ {{- template "_internal/opengraph.html" . -}} {{- template "_internal/google_news.html" . -}} {{- template "_internal/schema.html" . -}} - {{- template "_internal/twitter_cards.html" . -}} + <!-- {{- template "_internal/twitter_cards.html" . -}} --> + {{- partial "twitter_cards.html" . -}} <!-- Polyfill for old browsers --> {{ `<!--[if lte IE 9]> diff --git a/layouts/partials/twitter_cards.html b/layouts/partials/twitter_cards.html new file mode 100644 index 0000000..794ba92 --- /dev/null +++ b/layouts/partials/twitter_cards.html @@ -0,0 +1,31 @@ +<!-- https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/twitter_cards.html --> +{{- with $.Params.images -}} +<meta name="twitter:card" content="summary_large_image"/> +<meta name="twitter:image" content="{{ index . 0 | absURL }}"/> +{{ else -}} +{{- $images := $.Resources.ByType "image" -}} +{{- $featured := $images.GetMatch "*feature*" -}} +{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} +{{- with $featured -}} +<meta name="twitter:card" content="summary_large_image"/> +<meta name="twitter:image" content="{{ $featured.Permalink }}"/> +{{- else -}} +{{- with $.Site.Params.images -}} +<meta name="twitter:card" content="summary_large_image"/> +<meta name="twitter:image" content="{{ index . 0 | absURL }}"/> +{{ else -}} +<meta name="twitter:card" content="summary"/> +<meta name="twitter:image" content="{{ .Site.BaseURL }}/img/{{ .Site.Params.avatar }}"/> +{{- end -}} +{{- 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 -}} |