Skip to content

Commit 4910312

Browse files
jmooringbep
authored andcommitted
tpl/tplimpl: Deprecate .Site.Social usage with internal templates
1 parent 1b5f78b commit 4910312

3 files changed

Lines changed: 30 additions & 7 deletions

File tree

docs/content/en/templates/internal.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ If no images are found at all, then an image-less Twitter `summary` card is used
184184

185185
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.
186186

187-
The `.Site.Social.twitter` variable is exposed from the configuration as the value for `twitter:site`.
187+
Set the value of `twitter:site` in your site configuration:
188188

189-
{{< code-toggle file="hugo" >}}
190-
[social]
191-
twitter = "GoHugoIO"
189+
{{< code-toggle file="hugo" copy=false >}}
190+
[params.social]
191+
twitter = "GoHugoIO"
192192
{{</ code-toggle >}}
193193

194194
NOTE: The `@` will be added for you

tpl/tplimpl/embedded/templates/opengraph.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,16 @@
4242
{{ end }}{{ end }}
4343
{{- end }}
4444

45+
{{- /* Deprecate site.Social.facebook_admin in favor of site.Params.social.facebook_admin */}}
46+
{{- $facebookAdmin := "" }}
47+
{{- with site.Params.social.facebook_admin }}
48+
{{- $facebookAdmin = . }}
49+
{{- else }}
50+
{{- with site.Social.facebook_admin }}
51+
{{- $facebookAdmin = . }}
52+
{{- warnf "The social key in site configuration is deprecated. Use params.social.facebook_admin instead." }}
53+
{{- end }}
54+
{{- end }}
55+
4556
{{- /* Facebook Page Admin ID for Domain Insights */}}
46-
{{- with .Site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}
57+
{{ with $facebookAdmin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}

tpl/tplimpl/embedded/templates/twitter_cards.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@
1919
{{- end }}
2020
<meta name="twitter:title" content="{{ .Title }}"/>
2121
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
22-
{{ with .Site.Social.twitter -}}
22+
23+
{{- /* Deprecate site.Social.twitter in favor of site.Params.social.twitter */}}
24+
{{- $twitterSite := "" }}
25+
{{- with site.Params.social.twitter }}
26+
{{- $twitterSite = . }}
27+
{{- else }}
28+
{{- with site.Social.twitter }}
29+
{{- $twitterSite = . }}
30+
{{- warnf "The social key in site configuration is deprecated. Use params.social.twitter instead." }}
31+
{{- end }}
32+
{{- end }}
33+
34+
{{- with $twitterSite }}
2335
<meta name="twitter:site" content="@{{ . }}"/>
24-
{{ end -}}
36+
{{- end }}

0 commit comments

Comments
 (0)