Update social card logic
This commit is contained in:
parent
b8de167466
commit
bda54f97d8
@ -214,7 +214,7 @@ enableRobotsTXT = true
|
|||||||
|
|
||||||
# Social media. Delete any item you aren't using to make sure it won't show up
|
# Social media. Delete any item you aren't using to make sure it won't show up
|
||||||
# in your website's metadata.
|
# in your website's metadata.
|
||||||
[social]
|
[params.social]
|
||||||
email = "me@example.com" # Added to the footer so readers can reply to posts
|
email = "me@example.com" # Added to the footer so readers can reply to posts
|
||||||
twitter = "example" # Twitter handle (without '@')
|
twitter = "example" # Twitter handle (without '@')
|
||||||
facebook_admin = "0000000000" # Facebook Page Admin ID
|
facebook_admin = "0000000000" # Facebook Page Admin ID
|
||||||
|
@ -76,7 +76,7 @@ enableRobotsTXT = true
|
|||||||
|
|
||||||
# Social media. Delete any item you aren't using to make sure it won't show up
|
# Social media. Delete any item you aren't using to make sure it won't show up
|
||||||
# in your website's metadata.
|
# in your website's metadata.
|
||||||
[social]
|
[params.social]
|
||||||
email = "me@example.com" # Added to the footer so readers can reply to posts
|
email = "me@example.com" # Added to the footer so readers can reply to posts
|
||||||
twitter = "example" # Twitter handle (without '@')
|
twitter = "example" # Twitter handle (without '@')
|
||||||
facebook_admin = "0000000000" # Facebook Page Admin ID
|
facebook_admin = "0000000000" # Facebook Page Admin ID
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<a class="blog-tags" href="{{ .Permalink }}">#{{ .LinkTitle }}</a>
|
<a class="blog-tags" href="{{ .Permalink }}">#{{ .LinkTitle }}</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</p>
|
</p>
|
||||||
{{ with .Site.Social.email }}
|
{{ with .Site.Params.social.email }}
|
||||||
<p>
|
<p>
|
||||||
<a href='mailto:{{ . }}?subject={{ i18n "email-subject" }}"{{ default $.Site.Title $.Page.Title }}"'>
|
<a href='mailto:{{ . }}?subject={{ i18n "email-subject" }}"{{ default $.Site.Title $.Page.Title }}"'>
|
||||||
{{ i18n "email-reply" }} ↪
|
{{ i18n "email-reply" }} ↪
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
{{ $card := $card.Resize "900x webp q100" }}
|
{{ $card := $card.Resize "900x webp q100" }}
|
||||||
|
|
||||||
<!-- Open Graph / Facebook -->
|
<!-- Open Graph / Facebook -->
|
||||||
<!-- Source: https://raw.githubusercontent.com/gohugoio/hugo/master/tpl/tplimpl/embedded/templates/opengraph.html -->
|
<!-- Source: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/opengraph.html -->
|
||||||
<meta property="og:title" content="{{ .Title }}" />
|
<meta property="og:title" content="{{ .Title }}" />
|
||||||
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
|
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
|
||||||
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
|
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
|
||||||
@ -63,22 +63,52 @@
|
|||||||
{{ end }}{{ end }}
|
{{ end }}{{ end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
{{- /* Deprecate site.Social.facebook_admin in favor of site.Params.social.facebook_admin */}}
|
||||||
|
{{- $facebookAdmin := "" }}
|
||||||
|
{{- with site.Params.social }}
|
||||||
|
{{- if reflect.IsMap . }}
|
||||||
|
{{- $facebookAdmin = .facebook_admin }}
|
||||||
|
{{- end }}
|
||||||
|
{{- 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 */}}
|
{{- /* Facebook Page Admin ID for Domain Insights */}}
|
||||||
{{- with .Site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}
|
{{ with $facebookAdmin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}
|
||||||
|
|
||||||
<!-- Twitter -->
|
<!-- Twitter -->
|
||||||
<!-- Source: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/twitter_cards.html -->
|
<!-- Source: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/twitter_cards.html -->
|
||||||
<meta name="twitter:card" content="summary_large_image"/>
|
<meta name="twitter:card" content="summary_large_image"/>
|
||||||
<meta name="twitter:image" content="{{ $card.Permalink | absURL }}"/>
|
<meta name="twitter:image" content="{{ $card.Permalink | absURL }}"/>
|
||||||
|
|
||||||
<meta name="twitter:title" content="{{ .Title }}"/>
|
<meta name="twitter:title" content="{{ .Title }}"/>
|
||||||
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
|
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
|
||||||
{{ with .Site.Social.twitter -}}
|
|
||||||
<meta name="twitter:site" content="@{{ . }}"/>
|
{{- /* Deprecate site.Social.twitter in favor of site.Params.social.twitter */}}
|
||||||
{{ end -}}
|
{{- $twitterSite := "" }}
|
||||||
|
{{- with site.Params.social }}
|
||||||
|
{{- if reflect.IsMap . }}
|
||||||
|
{{- $twitterSite = .twitter }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
{{- with site.Social.twitter }}
|
||||||
|
{{- $twitterSite = . }}
|
||||||
|
{{- warnf "The social key in site configuration is deprecated. Use params.social.twitter instead." }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- with $twitterSite }}
|
||||||
|
{{- $content := . }}
|
||||||
|
{{- if not (strings.HasPrefix . "@") }}
|
||||||
|
{{- $content = printf "@%v" $twitterSite }}
|
||||||
|
{{- end }}
|
||||||
|
<meta name="twitter:site" content="{{ $content }}"/>
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
<!-- Microdata -->
|
<!-- Microdata -->
|
||||||
<!-- Source: https://raw.githubusercontent.com/gohugoio/hugo/master/tpl/tplimpl/embedded/templates/schema.html -->
|
<!-- Source: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/schema.html -->
|
||||||
<meta itemprop="name" content="{{ .Title }}">
|
<meta itemprop="name" content="{{ .Title }}">
|
||||||
<meta itemprop="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
<meta itemprop="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user