cremeaux/layouts/partials/social_metadata.html

50 lines
2.5 KiB
HTML

{{/* https://github.com/msfjarvis/hugo-social-metadata */}}
<!-- Configure meta and title tags -->
<meta property="og:type" content="website" />
{{ if .Site.Params.TwitterCardType }}
<meta name="twitter:card" content="{{ .Site.Params.TwitterCardType }}" />
{{ else }}
<meta name="twitter:card" content="summary_large_image" />
{{ end }}
{{ if .Site.Params.TwitterUsername }}
<meta name="twitter:site" content="{{ .Site.Params.TwitterUsername }}" />
{{ end }}
{{ if .IsHome }}
<title>{{ .Title }}</title>
<meta name="description" content="{{ $.Site.Params.description }}" />
<meta name="keywords" content="{{ $.Site.Params.Keywords }}" />
<meta property="og:image" content="{{ .Site.BaseURL}}{{ .Site.Params.SocialImage }}" />
<meta property="og:url" content="{{ .Site.BaseURL }}" />
<meta property="og:title" content="{{ .Title }}" />
<meta name="og:description" content="{{ $.Site.Params.description }}" />
<meta name="twitter:title" content="{{ .Title }}" />
<meta name="twitter:description" content="{{ $.Site.Params.description }}" />
<meta name="twitter:url" content="{{ .Site.BaseURL }}" />
<meta name="twitter:image:src" content="{{ .Site.BaseURL}}{{ .Site.Params.SocialImage }}" />
{{ else }}
<title>{{ plainify (.RenderString .Title) }} &middot; {{ .Site.Title }}</title>
<meta name="description" content="{{ .Description }}" />
{{ if .Params.tags }}
<meta name="keywords" content="{{ range .Params.tags }}{{ . }},{{ end }}" />
{{ else }}
<meta name="keywords" content="{{ $.Site.Params.Keywords }}" />
{{ end }}
<meta property="og:url" content="{{ .Permalink }}" />
<meta property="og:title" content="{{ plainify (.RenderString .Title) }} &middot; {{ .Site.Title }}" />
<meta name="twitter:title" content="{{ plainify (.RenderString .Title) }} &middot; {{ .Site.Title }}" />
{{ if .Description }}
<meta name="og:description" content="{{ .Description }}" />
<meta name="twitter:description" content="{{ .Description }}" />
{{ else }}
<meta name="og:description" content="{{ $.Site.Params.description }}" />
<meta name="twitter:description" content="{{ $.Site.Params.description }}" />
{{ end }}
<meta name="twitter:url" content="{{ .Permalink }}" />
{{ if .Params.SocialImage }}
<meta name="twitter:image:src" content="{{ .Site.BaseURL }}{{ .Params.SocialImage }}" />
{{ else }}
<meta name="twitter:image:src" content="{{ .Site.Params.SocialImage }}" />
{{ end }}
{{ end }}