brainbaking/themes/brainbaking-minimal/layouts/partials/head-meta.html

156 lines
5.6 KiB
HTML

{{ $perm := .Permalink }}
{{ $base := .Site.BaseURL }}
{{ $logo := "img/logo.png" }}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="dark light">
<link rel="canonical" href="{{ $perm }}">
<link rel="me" title="Mastodon" href="{{ .Site.Author.mastodonlink }}" />
<link rel="me" title="Github" href="{{ .Site.Author.githublink }}" />
<link rel="author" href="{{ $base }}humans.txt" type="text/plain" />
<link rel="webmention" href="{{ .Site.Params.webmentionServer }}/webmention" />
<link rel="pingback" href="{{ .Site.Params.webmentionServer }}/pingback" />
<!-- meta data tags, open graph -->
<meta name="twitter:title" content="{{ .Title }}" property="og:title">
{{ $isHomePage := eq .Title .Site.Title }}
{{ if .Params.subtitle }}
<meta name="description" content="{{ .Params.subtitle }}">
<meta name="twitter:description" content="{{ .Params.subtitle }}" property="og:description">
{{ else }}
{{ if .Summary }}
<meta name="description" content="{{ .Summary | safeHTML | truncate 50 }}">
<meta name="twitter:description" content="{{ .Summary | safeHTML | truncate 50 }}" property="og:description">
{{ else }}
<meta name="description" content="{{ .Site.Title }} | {{ .Site.Params.description }}">
<meta name="twitter:description" content="{{ .Site.Title }} | {{ .Site.Params.description }}" property="og:description">
{{ end }}
{{ end }}
{{ if .Keywords }}
<meta content="{{ delimit .Keywords ", " }}" name="keywords">
{{ else if .Params.tags }}
<meta content="{{ delimit .Params.tags ", " }}" name="keywords">
{{ end }}
<meta name="twitter:card" content="summary_large_image">
<meta property="og:url" content="{{ $perm }}" />
<meta property="og:type" content="{{ if .Params.type }}{{ .Params.type }}{{ else }}website{{ end }}" />
{{ $thumb := $logo | absURL }}
{{ if .Params.bigimg }}
{{- $image := resources.Get (printf "%s%s" "bigimg/" .Params.bigimg ) -}}
{{ if eq $image nil }}
{{ else }}
{{- $imgsmall := $image.Resize "768x jpg q70" }}
{{ $thumb = $imgsmall.Permalink }}
{{- $imgmedium := $image.Resize "960x jpg q85" }}
<meta property="og:image:width" content="{{ $imgsmall.Width }}" />
<meta property="og:image:height" content="{{ $imgsmall.Height }}" />
<style>
.big-img {
background-image: url({{ $imgsmall.RelPermalink }}) !important;
}
@media (min-width: 768px) {
.big-img {
background-image: url({{ $imgmedium.RelPermalink }}) !important;
}
}
@media (min-width: 960px) {
.big-img {
background-image: url({{ $image.RelPermalink }}) !important;
}
}
</style>
{{ end }}
{{ else }}
{{ $match := findRE `!\[(.*)\]\((.+).(jpg|png|gif)` .RawContent 1 }}
{{ range $match }}
{{ $relthumb := replaceRE `!\[(.*)\]\(` "" . }}
{{ if hasPrefix $relthumb "/" }}
{{ $thumb = printf "%s%s" $base $relthumb }}
{{ else }}
{{ $thumb = printf "%s%s" $perm $relthumb }}
{{ end }}
{{ end }}
{{ end }}
<meta name="twitter:image" property="og:image" content="{{ $thumb }}" />
{{ if .Params.subtitle }}
<meta name="twitter:image:alt" content="{{ .Params.subtitle }}">
{{ else }}
<meta name="twitter:image:alt" content="{{ .Summary | truncate 50 }}">
{{ end }}
<!-- zie sidebar.html, zelfde logica gebruikt -->
{{ $related := first 3 (where (where (where .Site.Pages.ByDate.Reverse ".Type" "==" "post") ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" $perm) }}
{{ if $related }}
{{ range $related }}
<meta property="og:see_also" content="{{ $perm }}" />
{{ end }}
{{ end }}
<meta property="article:published_time" content="{{ .PublishDate }}" />
<meta property="article:modified_time" content="{{ .Date }}" />
<meta property="article:section" content="{{ .Section }}" />
{{ with .Params.tags }}{{ range first 6 . }}
<meta property="article:tag" content="{{ . }}" />
{{ end }}{{ end }}
<!-- end og -->
<!-- structured data -->
{{ $ISO8601 := "2006-01-02T15:04:05-07:00" }}
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "BlogPosting",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": {{ $base }}
},
"articleSection" : "{{ .Section }}",
"name" : {{ .Title }},
{{ if .Params.subtitle }}
"headline" : {{ .Params.subtitle }},
{{ else }}
"headline" : {{ .Summary | safeHTML | truncate 50 }},
{{ end }}
"description" : {{ if .Description }}{{ .Description }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ end }}{{ end }},
{{ if isset .Params "language" }}
"inLanguage" : "{{ .Params.language }}",
{{ else }}
"inLanguage" : "en-US",
{{ end }}
"isFamilyFriendly": "true",
"image": {{ $thumb }},
"author" : {
"@type": "Person",
"name": "{{ .Site.Author.name }}"
},
"creator" : {
"@type": "Person",
"name": "{{ .Site.Author.name }}"
},
"publisher": {
"@type": "Organization",
"name": "{{ .Site.Title }}",
"url": {{ $base }},
"logo": {
"@type": "ImageObject",
"url": {{ $logo | absURL }},
"width":"32",
"height":"32"
}
},
"accountablePerson" : "{{ .Site.Author.name }}",
"copyrightHolder" : "{{ .Site.Title }}",
"copyrightYear" : "{{ .Date.Format "2006" }}",
"dateCreated": {{ .Date.Format $ISO8601 }},
"datePublished": {{ .PublishDate.Format $ISO8601 }},
"dateModified": {{ .Lastmod.Format $ISO8601 }},
"url" : {{ $perm }},
"wordCount" : "{{ .WordCount }}",
"keywords" : [ {{ if isset .Params "tags" }}{{ range .Params.tags }}{{ . }},{{ end }}{{ end }}{{ .Title }}, {{ .Section }} ]
}
</script>