{%- if page.title == nil -%}
    {%- comment -%}
    # This is a very hacky way to extract the page title from pages that do not have
    # front-matter yaml, but have a H1 header. We need to take (id-) attributes into
    # account, so some hacking is needed. Taking the following example:
    # <h1 id="docker-run-reference">Docker run reference</h1>
    #
    # a. split on '<h1', which gives us ['content before', '<h1 id="docker-run-reference">Docker run reference</h1>']
    # b. split the last element on '</h1', which gives us ['<h1 id="docker-run-reference">Docker run reference', '</h1', '>']
    # c. split the first element on '>', which gives us ['<h1 id="docker-run-reference"', '>', 'Docker run reference']
    {%- endcomment -%}
    {%- assign a = content | split: '<h1' | last -%}
    {%- assign b = a | split: '</h1' | first -%}
    {%- assign c = b | split: '>' | last -%}
    {%- assign page_title = c | strip_html | strip | truncatewords: 10 | escape_once -%}
{%- endif -%}
{%- if page.description == nil and page.datafile != nil and page.datafile != '' -%}
    {%- assign yaml_data = site.data[page.datafolder][page.datafile] -%}
    {%- if yaml_data.long and yaml_data.long != '' -%}
        {%- assign page_description = page.title | append: ': ' | append: yaml_data.long | strip_html | strip | truncatewords: 30 -%}
    {%- elsif yaml_data.short and yaml_data.short != '' -%}
        {%- assign page_description = page.title | append: ': ' | append: yaml_data.short | strip_html | strip | truncatewords: 30 -%}
    {%- else -%}
        {%- assign page_description = content | strip_html | strip | truncatewords: 30 -%}
    {%- endif -%}
{%- endif -%}
{%- assign domain_name = 'https://docs.docker.com' -%}
{%- if jekyll.environment == 'development' -%}
{%- assign domain_name = 'https://localhost:4000' -%}
{%- endif -%}
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  {%- if page.sitemap == false or site.GH_ENV == "gh_pages" %}
  <meta name="robots" content="noindex"/>
  {%- endif %}
  {%- if jekyll.environment == 'production' and site.google_analytics != '' -%}{%- include analytics/google_analytics.html GOOGLE_ID=site.google_analytics -%}{%- endif -%}
  <title>{{ page.title | default: page_title }} | Docker Documentation</title>
  <meta name="description" content="{{ page.description | default: page_description | escape}}" />
  <meta name="keywords" content="{{ page.keywords | default: 'docker, docker open source, docker platform, distributed applications, microservices, containers, docker containers, docker software, docker virtualization' }}">
  <link rel="canonical" href="{{ domain_name }}{{ page.url }}" />

  <!-- favicon -->
  <link rel="icon" type="image/x-icon" href="/favicons/docs@2x.ico" sizes="129x128">
  <link rel="apple-touch-icon" type="image/x-icon" href="/favicons/docs@2x.ico" sizes="129x128">
  <meta name="msapplication-TileImage" content="/favicons/docs@2x.ico">
  <meta property="og:image" content="/favicons/docs@2x.ico"/>
  <meta name="theme-color" content="#2496ed" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  {%- comment -%}
  We put these scripts in the head section, but use "defer" loading to allow the
  browser to start loading them as soon as possible. Actual execution of deferred
  scripts happens once the HTML is fully parsed.
  see https://flaviocopes.com/javascript-async-defer/#with-defer-in-the-head
  {%- endcomment -%}
  {%- if page.layout == 'landing' -%}
  <!-- landing page scripts -->
  <script defer src="/js/theme-switcher.js"></script>
  <script defer src="/js/jquery.js"></script>
  <script defer src="/js/bootstrap.min.js"></script>
  {%- else -%}
  <script defer src="/js/theme-switcher.js"></script>
  <script defer src="/js/anchorlinks.js"></script>
  <script defer src="/js/jquery.js"></script>
  <script defer src="/js/bootstrap.min.js"></script>
  <script defer src="/js/docs.js"></script>
  {%- endif -%}
  {%- if site.local_search -%}
  <script defer src="/js/search.js"></script>
  {%- endif -%}

  {%- comment -%}
  preload fonts: https://www.freecodecamp.org/news/web-fonts-in-2018-f191a48367e8/
  we only preload the "woff2" variants, as older formats (woff, eot) are only used
  by older browsers, and we don't optimize for those.
  {%- endcomment -%}
  <link rel="preload" as="font" href="https://fonts.gstatic.com/s/opensans/v18/mem8YaGs126MiZpBA-UFVZ0bf8pkAg.woff2" type="font/woff2" crossorigin="anonymous">
  <link rel="preload" as="font" href="/fonts/geomanist/hinted-Geomanist-Book.woff2"    type="font/woff2" crossorigin="anonymous">
  <link rel="preload" as="font" href="/fonts/geomanist/hinted-Geomanist-Regular.woff2" type="font/woff2" crossorigin="anonymous">
  <link rel="preload" as="font" href="/fonts/glyphicons-halflings-regular.woff2"       type="font/woff2" crossorigin="anonymous">
  <link rel="preload" as="font" href="/fonts/fontawesome-webfont.woff2?v=4.7.0"        type="font/woff2" crossorigin="anonymous">

  <link rel="stylesheet" href="/css/font-awesome.min.css">
  <link rel="stylesheet" href="/css/bootstrap.min.css">
  <link rel="stylesheet" href="/css/style.css" id="pagestyle">

  <!-- SEO stuff -->
  <meta name="twitter:title" itemprop="title name" content="{{ page.title | default: page_title }}"/>
  <meta name="twitter:description" property="og:description" itemprop="description" content="{{ page_description | escape_once }}" />
  <meta name="twitter:card" content="summary"/>
  <meta name="twitter:domain" content="docs.docker.com"/>
  <meta name="twitter:site" content="@docker_docs"/>
  <meta name="twitter:url" content="https://twitter.com/docker_docs"/>
  <meta name="twitter:image:src" content="/images/docs@2x.png"/>
  <meta name="twitter:image:alt" content="Docker Documentation"/>
  <meta property="og:title" content="{{ page.title | default: page_title }}" />
  <meta property="og:description" content="{{ page.description | default: page_description | escape_once }}" />
  <meta property="og:type" content="website"/>
  <meta property="og:updated_time" itemprop="dateUpdated" content="{% if page.date %}{{ page.date | date_to_xmlschema }}{% else %}{{ site.time | date_to_xmlschema }}{% endif %}"/>
  <meta property="og:image" itemprop="image primaryImageOfPage" content="/images/docs@2x.png"/>
  <meta property="og:locale" content="en_US" />
  <meta property="og:url" content="https://docs.docker.com{{ page.url }}" />
  <meta property="og:site_name" content="Docker Documentation" />
  <meta property="article:published_time" itemprop="datePublished" content="{% if page.date %}{{ page.date | date_to_xmlschema }}{% else %}{{ site.time | date_to_xmlschema }}{% endif %}"/>
  <script type="application/ld+json">{"@context":"http://schema.org","@type":"WebPage","headline":{{ page.title | default: page_title | jsonify }},"description":{{ page.description | default: page_description | jsonify }},"url":"https://docs.docker.com{{ page.url }}"}</script>
  <!-- END SEO STUFF -->
</head>
