From 4910312ee75a1c67fad68c259ad9576dca854c62 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Mon, 16 Oct 2023 17:43:11 -0700 Subject: tpl/tplimpl: Deprecate .Site.Social usage with internal templates --- docs/content/en/templates/internal.md | 8 ++++---- tpl/tplimpl/embedded/templates/opengraph.html | 13 ++++++++++++- tpl/tplimpl/embedded/templates/twitter_cards.html | 16 ++++++++++++++-- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/docs/content/en/templates/internal.md b/docs/content/en/templates/internal.md index ee0d7258d..56315ec2c 100644 --- a/docs/content/en/templates/internal.md +++ b/docs/content/en/templates/internal.md @@ -184,11 +184,11 @@ If no images are found at all, then an image-less Twitter `summary` card is used Hugo uses the page title and description for the card's title and description fields. The page summary is used if no description is given. -The `.Site.Social.twitter` variable is exposed from the configuration as the value for `twitter:site`. +Set the value of `twitter:site` in your site configuration: -{{< code-toggle file="hugo" >}} -[social] - twitter = "GoHugoIO" +{{< code-toggle file="hugo" copy=false >}} +[params.social] +twitter = "GoHugoIO" {{}} NOTE: The `@` will be added for you diff --git a/tpl/tplimpl/embedded/templates/opengraph.html b/tpl/tplimpl/embedded/templates/opengraph.html index a9d4dd83c..f5a4ebd9f 100644 --- a/tpl/tplimpl/embedded/templates/opengraph.html +++ b/tpl/tplimpl/embedded/templates/opengraph.html @@ -42,5 +42,16 @@ {{ end }}{{ end }} {{- end }} +{{- /* Deprecate site.Social.facebook_admin in favor of site.Params.social.facebook_admin */}} +{{- $facebookAdmin := "" }} +{{- with site.Params.social.facebook_admin }} + {{- $facebookAdmin = . }} +{{- else }} + {{- with site.Social.facebook_admin }} + {{- $facebookAdmin = . }} + {{- warnf "The social key in site configuration is deprecated. Use params.social.facebook_admin instead." }} + {{- end }} +{{- end }} + {{- /* Facebook Page Admin ID for Domain Insights */}} -{{- with .Site.Social.facebook_admin }}{{ end }} +{{ with $facebookAdmin }}{{ end }} diff --git a/tpl/tplimpl/embedded/templates/twitter_cards.html b/tpl/tplimpl/embedded/templates/twitter_cards.html index 83a3b79c4..4a753bba6 100644 --- a/tpl/tplimpl/embedded/templates/twitter_cards.html +++ b/tpl/tplimpl/embedded/templates/twitter_cards.html @@ -19,6 +19,18 @@ {{- end }} -{{ with .Site.Social.twitter -}} + +{{- /* Deprecate site.Social.twitter in favor of site.Params.social.twitter */}} +{{- $twitterSite := "" }} +{{- with site.Params.social.twitter }} + {{- $twitterSite = . }} +{{- else }} + {{- with site.Social.twitter }} + {{- $twitterSite = . }} + {{- warnf "The social key in site configuration is deprecated. Use params.social.twitter instead." }} + {{- end }} +{{- end }} + +{{- with $twitterSite }} -{{ end -}} +{{- end }} -- cgit v1.2.3