diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-05-25 00:01:42 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-05-25 00:01:42 +0200 |
| commit | abe3b6761139a97ce535486af2f6918f2a8c0051 (patch) | |
| tree | 0619acb48c28dd9d29110eee6841f5912bff8d35 /layouts/partials/templates/twitter_cards.html | |
| parent | cd9b95683a8ec2c2ef86863c61025ae8a6fc4222 (diff) | |
| download | gohugo-theme-ed-abe3b6761139a97ce535486af2f6918f2a8c0051.tar.gz | |
Add ability to create twitter cards
Diffstat (limited to 'layouts/partials/templates/twitter_cards.html')
| -rw-r--r-- | layouts/partials/templates/twitter_cards.html | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/layouts/partials/templates/twitter_cards.html b/layouts/partials/templates/twitter_cards.html new file mode 100644 index 0000000..970c137 --- /dev/null +++ b/layouts/partials/templates/twitter_cards.html @@ -0,0 +1,19 @@ + <!-- Twitter Card metadata --> + <meta name="twitter:title" content="{{- partial "title.html" . -}}"> + <meta name="twitter:description" content="{{ (partial "description.html" . ) }}"> + + {{- /* Twitter username for the website used in the card footer */}} + {{- with site.Social.twitter }} + <meta name="twitter:site" content="@{{ . }}"> + {{- end }} + + {{- $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) -}} + {{- $image := .Resources.GetMatch .Params.featured_image -}} + + {{- if and .IsPage $image }} + <meta name="twitter:card" content="summary_large_image"> + <meta name="twitter:image" content="{{ $image.Permalink }}"> + {{- else }} + <meta name="twitter:card" content="summary_large_image"> + <meta name="twitter:image" content="{{ $logo.Permalink }}"> + {{- end -}} |
