<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="referrer" content="no-referrer-when-downgrade">
  <% var seo = config.seo || {} %>
  <meta name="baidu-site-verification" content="<%= seo.baidu_site_verification %>" />
  <meta name="google-site-verification" content="<%= seo.google_site_verification %>" />
  <meta name="msvalidate.01" content="<%= seo.ms_site_verification %>" />
  <meta name="360-site-verification" content="<%= seo._360_site_verification %>" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- if page has tags, then add tags to keyword -->
  <% var tags_str = (page.tags || []).map((tag)=>tag.name).join(',') %>
  <% var keywords_str = (page.keywords || []).join(',') %>
  <meta name="keywords" content="<%= [config.keyword, tags_str, keywords_str].join(',').replace(',,', ',') %>">
  <!-- page.description has higher priority -->
  <meta name="description" content="<%= page.description || config.description %>">
  <link rel="shortcut icon" href="<%= config.root %><%= config.header_icon %>">
  <title>
    <% if (page.title) {  var parts = [page.title, page.seo_title, config.seo_title || config.title] %>
    <%= parts.filter(item => item).join(' | ') %>
    <% } else {%>
    <%= config.title %>
    <% } %>
  </title>

  <link rel="canonical" href="<%= (config.url||'') %><%= config.root %><%= (page.path||'').replace('index.html', '') %>">
  <%- css('css/geektutu')%>
  <!-- global function -->
  <script>
    window.globalAddScript = function (url, onload, onerror) {
      var s = document.createElement('script');
      s.src = url;
      onload && (s.onload = onload);
      onerror && (s.onerror = onerror);
      document.body.appendChild(s);
    }
    window.globalAddCss = function (url) {
      var s = document.createElement('link');
      s.rel = 'stylesheet';
      s.href = url;
      document.body.appendChild(s);
    }
    window.getPosition = function (ele) {
      var x = 0, y = 0;
      while (ele) {
        x += (ele.offsetLeft - ele.scrollLeft + ele.clientLeft);
        y += (ele.offsetTop - ele.scrollTop + ele.clientTop);
        ele = ele.offsetParent;
      }
      return { x: x, y: y };
    }
    window.getDom = function (str) { return document.querySelector(str) }
  </script>
  <!-- google ad -->
  <% if (config.google_ad_client) { %>
  <script>
    window.addEventListener('load', function () {
      globalAddScript("https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js", "", function (e) {
        if (window.localStorage.getItem('gkt_marker')) {
          var rec = document.querySelector('.gkt-rec-links');
          rec && (rec.style.display = 'none');
        }
      });
    });
    (adsbygoogle = window.adsbygoogle || []).push({
      google_ad_client: "<%- config.google_ad_client %>",
      enable_page_level_ads: true
    });
  </script>
  <% } %>
</head>