<head>
  <% if (theme.injector.head_begin) { %>
    <%- render(theme.injector.head_begin, 'html'); %>
  <% } %>
  <meta charset="utf-8">
  <%- partial('analytics/google-analytics', null, { cache: true }) %>
  <%- partial('analytics/clarity', null, { cache: true }) %>
  <%- partial('analytics/baidu-analytics', null, { cache: true }) %>
  <%- themeConfig() %>
  <%
    let title = page.title;
    if (is_archive()) {
      title = __('archive_a');
      if (is_month()) {
        title += ': ' + page.year + '/' + page.month;
      } else if (is_year()) {
        title += ': ' + page.year;
      }
    } else if (is_category()) {
      title = __('category') + ': ' + page.category;
    } else if (is_tag()) {
      title = __('tag') + ': ' + page.tag;
    }
  %>
  <title>
    <% if (title) { %><%= title %> |
    <% } %>
    <%= config.title %>
  </title>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <% if (theme.custom_font?.enable) { %>
    <%- vendorFont() %>
  <% } %>
  <% if (theme.font?.enable) { %>
    <%- vendorGoogleFont() %>
  <% } %>
  <% if (!theme.icon_font) { %>
    <%- css(theme.vendor.css.fontawesome.high_priority.map(i => ({href: vendorCdn(i)[0], integrity: vendorCdnIntegrity(i)[0], crossorigin: "anonymous"}))) %>
    <%- asyncCss(theme.vendor.css.fontawesome.low_priority.map(i => ({href: vendorCdn(i)[0], integrity: vendorCdnIntegrity(i)[0], crossorigin: "anonymous"}))) %>
  <% } else { %>
    <link rel="preload" href="//at.alicdn.com/t/c/font_<%- theme.icon_font %>.woff2" as="font" type="font/woff2" crossorigin="anonymous">
  <% } %>
  <% if (theme.preloader.enable) { %>
    <%- css('css/loader') %>
  <% } %>
  <% if (theme.open_graph) { %>
    <%- open_graph({image: page.photos || theme.open_graph.options?.default_og_image || [], twitter_card: theme.open_graph.options?.twitter_card, twitter_id: theme.open_graph.options?.twitter_id, twitter_site: theme.open_graph.options?.twitter_site, twitter_image: theme.open_graph.options?.twitter_image, google_plus: theme.open_graph.options?.google_plus, fb_admins: theme.open_graph.options?.fb_admins, fb_app_id: theme.open_graph.options?.fb_app_id}) %>
  <% } %>
  <% if (config.feed) { %>
    <%- feed_tag() %>
  <% } else if (theme.rss) { %>
    <%- feed_tag(theme.rss) %>
  <% } %>
  <% if (theme.favicon) { %>
    <%- favicon_tag(theme.favicon) %>
  <% } %>
  <%- css('css/style') %>
  <%- asyncCss({href: vendorCdn(theme.vendor.css.photoswipe)[0], integrity: vendorCdnIntegrity(theme.vendor.css.photoswipe)[0], crossorigin: "anonymous"}) %>
  <% if (theme.math.enable) { %>
    <% if (theme.math.katex.enable) { %>
      <% if (is_post() || is_page()) { %>
        <%- css({href: vendorCdn(theme.vendor.css.katex)[0], integrity: vendorCdnIntegrity(theme.vendor.css.katex)[0], crossorigin: "anonymous"}) %>
      <% } else { %>
        <%- asyncCss({href: vendorCdn(theme.vendor.css.katex)[0], integrity: vendorCdnIntegrity(theme.vendor.css.katex)[0], crossorigin: "anonymous"}) %>
      <% } %>
    <% } %>
  <% } %>
  <% if (theme.waline.enable && theme.waline.serverURL) { %>
    <% if (is_post() || is_page()) { %>
      <%- css({href: vendorCdn(theme.vendor.css.waline)[0], integrity: vendorCdnIntegrity(theme.vendor.css.waline)[0], crossorigin: "anonymous"}) %>
    <% } else { %>
      <%- asyncCss({href: vendorCdn(theme.vendor.css.waline)[0], integrity: vendorCdnIntegrity(theme.vendor.css.waline)[0], crossorigin: "anonymous"}) %>
    <% } %>
  <% } %>
  <% if (theme.gitalk.enable && theme.gitalk.clientID && theme.gitalk.clientSecret) { %>
    <% if (is_post() || is_page()) { %>
      <%- css({href: vendorCdn(theme.vendor.css.gitalk)[0], integrity: vendorCdnIntegrity(theme.vendor.css.gitalk)[0], crossorigin: "anonymous"}) %>
    <% } else { %>
      <%- asyncCss({href: vendorCdn(theme.vendor.css.gitalk)[0], integrity: vendorCdnIntegrity(theme.vendor.css.gitalk)[0], crossorigin: "anonymous"}) %>
    <% } %>
  <% } %>
  <% if (theme.pace.enable) { %>
    <%- js({src: vendorCdn(theme.vendor.js.pace)[0], integrity: vendorCdnIntegrity(theme.vendor.js.pace)[0], crossorigin: "anonymous"}) %>
  <% } %>
  <% if (theme.animation.enable) { %>
    <%- css({href: vendorCdn(theme.vendor.css.aos)[0], integrity: vendorCdnIntegrity(theme.vendor.css.aos)[0], crossorigin: "anonymous"}) %>
  <% } %>
  <% if (theme.player.aplayer.enable) { %>
    <%- css({href: vendorCdn(theme.vendor.css.aplayer)[0], integrity: vendorCdnIntegrity(theme.vendor.css.aplayer)[0], crossorigin: "anonymous"}) %>
  <% } %>
  <% if (theme.injector.head_end) { %>
    <%- render(theme.injector.head_end, 'html'); %>
  <% } %>
</head>
