<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
  <head>
    <!-- set variables -->
    {{- $title := "" -}}
    {{- if .IsHome -}}
        {{- $title = .Site.Title -}}
    {{- else -}}
        {{- if .Params.heading -}}
          {{- $title = .Params.heading -}}
        {{- else -}}
          {{- $title = printf "%s | %s" .Title .Site.Title -}}
        {{- end -}}
    {{- end -}}
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="author" content="{{ .Site.Params.Author.name }}" />
    {{ with .Site.Params.description }}<meta name="description" content="{{ . }}" />{{ end }}
    {{ with .Site.Params.keywords }}<meta name="keywords" content="{{ . }}" />{{ end }}
    <link rel="shortcut icon" type="image/x-icon" href="{{ .Site.BaseURL }}img/favicon.ico" />
    <link href="/blog/index.xml" rel="alternate" type="application/rss+xml" title="Max Mehl - blog feed">
    <link href="/categories/english/index.xml" rel="alternate" type="application/rss+xml" title="Max Mehl - blog feed (EN)">
    <link href="/categories/deutsch/index.xml" rel="alternate" type="application/rss+xml" title="Max Mehl - blog feed (DE)">
    <title>{{ $title }}</title>

    <!-- CSS and JS -->
    {{- partialCached "head/css.html" . }}

    <!-- Get image for social media sharing -->
    {{- $image := "" -}}
    {{- $imagesrc := (.Page.Params.headerimage.src | default .Site.Params.avatar) -}}
    {{- if eq .Page.BundleType "leaf" }}
      {{- with .Page.Resources.GetMatch $imagesrc }}
        {{- $image = . -}}
      {{- end }}
    {{- else }}
      {{- with resources.GetMatch (printf "**/%s" $imagesrc) }}
        {{- $image = . -}}
      {{- end }}
    {{- end }}
    {{- if $image }}
      {{- $image = $image.Fill "1200x630 jpg" -}}
    {{- end }}

    <!-- Open Graph meta-data (e.g. Facebook) -->
    <meta property="og:type" content="article"/>
    <meta property="og:site_name" content="{{ .Site.Title }}"/>
    <meta property="og:title" content="{{ $title }}"/>
    <meta property="og:url" content="{{ .Permalink }}"/>
    <meta property="og:description" content="{{ (.Summary | default .Site.Params.description) | truncate 200 }}"/>
    {{- with $image }}
    <meta property="og:image" content="{{ .Permalink }}"/>
    <meta property="og:image:type" content="{{ .MediaType }}">
    <meta property="og:image:width" content="{{ .Width }}">
    <meta property="og:image:height" content="{{ .Height }}">
    {{- end }}
  </head>
