From abe3b6761139a97ce535486af2f6918f2a8c0051 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Wed, 25 May 2022 00:01:42 +0200 Subject: Add ability to create twitter cards --- exampleSite/config.toml | 2 ++ layouts/partials/head.html | 1 + layouts/partials/templates/opengraph.html | 2 +- layouts/partials/templates/twitter_cards.html | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/templates/twitter_cards.html diff --git a/exampleSite/config.toml b/exampleSite/config.toml index eb8cb4e..3ea1e1c 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -156,6 +156,8 @@ disableKinds = ['RSS'] facebook_admin = '' # Facebook Page ID facebook_id = '' + # Twitter username for the website used in the card footer + twitter = 'john_doe' # For more see https://gohugo.io/content-management/menus/ [menu] diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 81dd2d0..24fd6f9 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -29,4 +29,5 @@ {{- /* Misc */}} {{ template "partials/templates/opengraph.html" . }} + {{ template "partials/templates/twitter_cards.html" . }} diff --git a/layouts/partials/templates/opengraph.html b/layouts/partials/templates/opengraph.html index fbee957..c65cdac 100644 --- a/layouts/partials/templates/opengraph.html +++ b/layouts/partials/templates/opengraph.html @@ -1,5 +1,5 @@ - + 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 username for the website used in the card footer */}} + {{- with site.Social.twitter }} + + {{- end }} + + {{- $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) -}} + {{- $image := .Resources.GetMatch .Params.featured_image -}} + + {{- if and .IsPage $image }} + + + {{- else }} + + + {{- end -}} -- cgit v1.2.3