Improve the preview card when sharing to social media (#9495)
* Improve social media share sheet metadata * Improve social media share sheet metadata * Improve social media share sheet metadata * Improve social media share sheet metadata
This commit is contained in:
parent
8394219fdf
commit
ae0c28db7c
|
|
@ -12,15 +12,16 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="shortcut icon" type="image/png" href="{{ "images/favicon.png" | relURL }}">
|
<link rel="shortcut icon" type="image/png" href="{{ "images/favicon.png" | relURL }}">
|
||||||
{{ partial "css.html" . }}
|
{{ partial "css.html" . }}
|
||||||
{{ if .Params.description }}
|
<!-- Content for social media sharing previews -->
|
||||||
<meta name="description" content="{{ .Params.description }}" />
|
<!-- Facebook uses the og: stuff, while Twitter and others use twitter: -->
|
||||||
<meta property="og:description" content="{{ .Params.description }}" />
|
<meta name="description" content="{{ if .Params.description }}{{ .Params.description }}{{ else }}{{ .Summary }}{{ end }}" />
|
||||||
{{ else }}
|
<meta property="og:description" content="{{ if .Params.description }}{{ .Params.description }}{{ else }}{{ .Summary }}{{ end }}" />
|
||||||
<meta name="description" content="{{ .Params.title }}" />
|
<meta property="twitter:description" content="{{ if .Params.description }}{{ .Params.description }}{{ else }}{{ .Summary }}{{ end }}" />
|
||||||
<meta property="og:description" content="{{ .Params.title }}" />
|
|
||||||
{{ end }}
|
|
||||||
<meta property="og:url" content="{{ .Permalink }}" />
|
<meta property="og:url" content="{{ .Permalink }}" />
|
||||||
<meta property="og:title" content="{{ if .Title }}{{ .Title }} - {{ end }}{{ .Site.Title }}" />
|
<meta name="og:title" content="{{ if .Params.title }}{{ .Title }}{{ else }}{{ .Summary | truncate 10 }}{{ end }}" />
|
||||||
|
<meta name="twitter:title" content="{{ if .Params.title }}{{ .Title }}{{ else }}{{ .Summary | truncate 10 }}{{ end }}" />
|
||||||
|
<!-- Alt text for the site image -->
|
||||||
|
<meta name="twitter:image:alt" content="{{ .Site.Title }}">
|
||||||
{{ if eq .Section "blog" }}
|
{{ if eq .Section "blog" }}
|
||||||
{{ with findRE "<img.*?>" .Content 1 }}
|
{{ with findRE "<img.*?>" .Content 1 }}
|
||||||
<meta property="og:image" content="{{ index . 0 | replaceRE ".*src=\"(.+?)\".*" "$1" }}" />
|
<meta property="og:image" content="{{ index . 0 | replaceRE ".*src=\"(.+?)\".*" "$1" }}" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue