feat: Adding Twitter and Social image preview including description (#207)

hugo
Simon Späti 2 years ago committed by GitHub
parent 6885651f7b
commit bde44fadf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,7 @@
<!-- set data/config yaml file based on website language --> <!-- set data/config yaml file based on website language -->
{{ $config := cond (eq $.Site.Language.Lang "en") "config" (printf "config.%s" $.Site.Language.Lang) }} {{ $config := cond (eq $.Site.Language.Lang "en") "config" (printf "config.%s" $.Site.Language.Lang) }}
{{ $data := index $.Site.Data $config }} {{ $data := index $.Site.Data $config }}
{{.Site.BaseURL}}icon.png
<head> <head>
<!-- Meta tags --> <!-- Meta tags -->
<meta charset="UTF-8" /> <meta charset="UTF-8" />
@ -8,6 +9,23 @@
name="description" name="description"
content="{{if .IsHome}}{{$data.description | default $.Site.Data.config.description}}{{else}}{{.Summary}}{{end}}" content="{{if .IsHome}}{{$data.description | default $.Site.Data.config.description}}{{else}}{{.Summary}}{{end}}"
/> />
<meta property="og:title" content="{{ .Title }}">
<meta property="og:type" content="website">
<meta property="og:image" content="{{.Site.BaseURL}}icon.png">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:width" content="200">
<meta property="og:height" content="200">
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="{{ .Title }}" />
<meta name="twitter:description" content="{{if .IsHome}}{{$data.description | default $.Site.Data.config.description}}{{else}}{{.Summary}}{{end}}" />
<meta name="twitter:image" content="{{.Site.BaseURL}}icon.png">
{{ range $data.links }}
{{ if strings.Contains .link "twitter.com" }}
{{ $twitter_handle := index (split .link "/") (sub (len (split .link "/")) 1) }}
<meta name="twitter:site" content="{{ $twitter_handle }}" />
{{ end }}
{{ end }}
<title> <title>
{{ if .Title }}{{ .Title }}{{ else }}{{ $data.page_title | default $.Site.Data.config.page_title }}{{ {{ if .Title }}{{ .Title }}{{ else }}{{ $data.page_title | default $.Site.Data.config.page_title }}{{
end }} end }}

Loading…
Cancel
Save