diff options
Diffstat (limited to 'layouts/partials/head-meta.html')
| -rw-r--r-- | layouts/partials/head-meta.html | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/layouts/partials/head-meta.html b/layouts/partials/head-meta.html new file mode 100644 index 0000000..34a60e2 --- /dev/null +++ b/layouts/partials/head-meta.html @@ -0,0 +1,57 @@ +{{/* description: per-page excerpt wins over site-wide description */}} +{{ $description := .Site.Language.Params.siteDescription }} +{{ with .Params.excerpt }}{{ $description = . }}{{ end }} + +{{/* og:type: "article" only for single content pages that have a date */}} +{{ $ogType := "website" }} +{{ if and (eq .Kind "page") .Date }}{{ $ogType = "article" }}{{ end }} + +{{/* og:image: page image wins; fall back to lamp for homepage, dark thumbnail for articles */}} +{{ $defaultImage := "images/default_thumbnail_dark.png" }} +{{ if .IsHome }}{{ $defaultImage = "images/lampD.png" }}{{ end }} +{{ $ogImage := printf "%s%s" .Site.BaseURL $defaultImage }} +{{ with .Params.image }}{{ $ogImage = printf "%s%s" $.Site.BaseURL (strings.TrimLeft "/" .) }}{{ end }} + +{{/* author: page-level param wins; fall back to site param */}} +{{ $author := .Site.Params.author }} +{{ with .Params.author }}{{ $author = . }}{{ end }} + +<meta name="description" content="{{ $description }}"> + +<meta property="og:title" content="{{ .Title }}"> +<meta property="og:description" content="{{ $description }}"> +<meta property="og:type" content="{{ $ogType }}"> +<meta property="og:url" content="{{ .Permalink }}"> +<meta property="og:site_name" content="{{ .Site.Title }}"> +<meta property="og:locale" content="{{ .Site.Language.Params.locale }}"> +<meta property="og:image" content="{{ $ogImage }}"> + +{{ if eq $ogType "article" }} +<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}"> +<meta property="article:author" content="{{ $author }}"> +{{ end }} + +<meta name="twitter:card" content="summary_large_image"> +<meta name="twitter:title" content="{{ .Title }}"> +<meta name="twitter:description" content="{{ $description }}"> +<meta name="twitter:image" content="{{ $ogImage }}"> +{{ with .Site.Params.twitterHandle }} +<meta name="twitter:site" content="@{{ . }}"> +{{ end }} + +{{/* SEO: Self-referencing canonical */}} +<link rel="canonical" href="{{ .Permalink }}"> + +{{/* SEO: hreflang alternates for all language variants */}} +{{ range .AllTranslations }} +<link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ .Permalink }}"> +{{ end }} +{{/* x-default: EN version (served at root /) */}} +{{ range .AllTranslations }} + {{ if eq .Language.Lang "en" }} +<link rel="alternate" hreflang="x-default" href="{{ .Permalink }}"> + {{ end }} +{{ end }} + +{{/* Structured data: BreadcrumbList JSON-LD (single pages and named sections) */}} +{{ if or (eq .Kind "page") (eq .Kind "section") }}{{ partial "breadcrumb-jsonld.html" . }}{{ end }} |
