hugo-theme-lowtech/layouts/partials/social_metadata.html

52 lines
2.6 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>{{ default .Site.Title .Title }}</title>
<meta name="description" content="{{ default $.Site.Params.description .Description }}" />
<meta property="og:image" content="{{ .Site.BaseURL}}{{ .Site.Params.SocialImage }}" />
<meta property="og:url" content="{{ .Site.BaseURL }}" />
<meta property="og:title" content="{{ default .Site.Title .Title }}" />
<meta name="og:description" content="{{ $.Site.Params.description }}" />
<meta name="twitter:title" content="{{ default .Site.Title .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>{{ .Title }} &middot; {{ .Site.Title }}</title>
<meta name="description" content="{{ .Description }}" />
<meta property="og:url" content="{{ .Permalink }}" />
<meta property="og:title" content="{{ .Title }} &middot; {{ .Site.Title }}" />
<meta name="twitter:title" content="{{ .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 }}
{{ if .Params.tags }}
<meta name="keywords" content="{{ range .Params.tags }}{{ . }},{{ end }}" />
{{ else if .Keywords }}
<meta name="keywords" content="{{ range .Keywords }}{{ . }},{{ end }}" />
{{ else }}
<meta name="keywords" content="{{ $.Site.Params.Keywords }}" />
{{ end }}