2 Commits

Author SHA1 Message Date
1f82ad4f0b Add support for twitter:creator tag
Put `twitter` metadata on an author
2025-07-05 02:06:39 -05:00
7e016547ec Remove redundant twitter tags since they falls back to opengraph 2025-07-05 01:46:42 -05:00

View File

@ -1,3 +1,7 @@
{{/* we do not need to duplicate what's already covered by OpenGraph tags
* see: https://demo.bbaovanc.com/test/remove-twitter-tags/blog/swapfile-guide/
* so, no twitter:image/title/description
*/}}
{{ $images := $.Resources.ByType "image" }}
{{ $featured := $images.GetMatch "*feature*" }}
{{ if not $featured }}
@ -17,13 +21,21 @@
{{ else }}
<meta name="twitter:card" content="summary">
{{ end }}
<meta name="twitter:image" content="{{ $featured.Permalink }}">
{{ else }}
<meta name="twitter:card" content="summary">
{{ end }}
<meta name="twitter:title" content="{{ .Title | plainify }}">
<meta name="twitter:description" content="{{ (partial "seo-description.html" .) | plainify }}">
{{/* twitter:site is the site author; twitter:creator is page author
* https://developer.x.com/en/docs/x-for-websites/cards/guides/getting-started
* "Card and Content Attribution"
*/}}
{{ with .Site.Params.social.twitter }}
<meta name="twitter:site" content="@{{ . }}">
{{ end }}
{{ with .GetTerms "authors" }}
{{ range . }}
{{ with .Params.twitter }}
<meta name="twitter:creator" content="@{{ . }}">
{{ end }}
{{ end }}
{{ end }}