head.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <head>
  2. <meta charset="utf-8">
  3. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  4. {% capture pagetitle %}
  5. {%- if page.share-title -%}
  6. {{ page.share-title | strip_html | xml_escape }}
  7. {%- elsif page.title -%}
  8. {{ page.title | strip_html | xml_escape }}
  9. {%- else -%}
  10. {{ site.title | strip_html | xml_escape }}
  11. {%- endif -%}
  12. {% endcapture %}
  13. {% capture title %}
  14. {%- if site.title and site.title-on-all-pages and (site.title != pagetitle) -%}
  15. {{ pagetitle }} | {{ site.title }}
  16. {%- else -%}
  17. {{ pagetitle }}
  18. {%- endif -%}
  19. {% endcapture %}
  20. {% capture description %}
  21. {%- if page.share-description -%}
  22. {{ page.share-description | strip_html | xml_escape }}
  23. {%- elsif page.subtitle -%}
  24. {{ page.subtitle | strip_html | xml_escape }}
  25. {%- else -%}
  26. {%- assign excerpt_length = site.excerpt_length | default: 50 -%}
  27. {{ page.content | strip_html | xml_escape | truncatewords: excerpt_length | strip }}
  28. {%- endif -%}
  29. {% endcapture %}
  30. <title>{{ title }}</title>
  31. {% capture author %}
  32. {%- if page.author -%}
  33. {{ page.author | strip_html }}
  34. {%- elsif site.author -%}
  35. {{ site.author }}
  36. {%- endif -%}
  37. {% endcapture %}
  38. {% if author != "" %}
  39. <meta name="author" content="{{ author }}">
  40. {% endif %}
  41. <meta name="description" content="{{ description }}">
  42. {% if site.mobile-theme-col %}
  43. <meta name="theme-color" content="{{ site.mobile-theme-col }}">
  44. {% endif %}
  45. {% if site.keywords %}
  46. <meta name="keywords" content="{{ site.keywords }}">
  47. {% endif %}
  48. {% if site.rss-description %}
  49. <link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ '/feed.xml' | absolute_url }}">
  50. {% endif %}
  51. {% include gtag.html %}
  52. {% include gtm_head.html %}
  53. {% include google_analytics.html %}
  54. {% include cloudflare_analytics.html %}
  55. {% include mathjax.html %}
  56. {% if layout.common-ext-css %}
  57. {% for css in layout.common-ext-css %}
  58. {% include ext-css.html css=css %}
  59. {% endfor %}
  60. {% endif %}
  61. {% if layout.common-css %}
  62. {% for css in layout.common-css %}
  63. <link rel="stylesheet" href="{{ css | relative_url }}">
  64. {% endfor %}
  65. {% endif %}
  66. {% if site.site-css %}
  67. {% for css in site.site-css %}
  68. <link rel="stylesheet" href="{{ css | relative_url }}">
  69. {% endfor %}
  70. {% endif %}
  71. {% if page.ext-css %}
  72. {% for css in page.ext-css %}
  73. {% include ext-css.html css=css %}
  74. {% endfor %}
  75. {% endif %}
  76. {% if page.css %}
  77. {% for css in page.css %}
  78. <link rel="stylesheet" href="{{ css | relative_url }}">
  79. {% endfor %}
  80. {% endif %}
  81. {% if site.fb_app_id %}
  82. <meta property="fb:app_id" content="{{ site.fb_app_id }}">
  83. {% endif %}
  84. {% if site.title %}
  85. <meta property="og:site_name" content="{{ site.title }}">
  86. {% endif %}
  87. {%- capture img -%}
  88. {%- if page.share-img -%}
  89. {{ page.share-img }}
  90. {%- elsif page.cover-img -%}
  91. {%- if page.cover-img.first -%}
  92. {{ page.cover-img[0].first.first }}
  93. {%- else -%}
  94. {{ page.cover-img }}
  95. {%- endif -%}
  96. {%- elsif page.thumbnail-img -%}
  97. {{ page.thumbnail-img }}
  98. {%- elsif site.avatar -%}
  99. {{ site.avatar }}
  100. {% endif %}
  101. {%- endcapture -%}
  102. {%- assign img=img | strip -%}
  103. <meta property="og:title" content="{{ title }}">
  104. <meta property="og:description" content="{{ description }}">
  105. {% if img != "" %}
  106. <meta property="og:image" content="{{ img | absolute_url }}">
  107. {% endif %}
  108. {% if page.id %}
  109. <meta property="og:type" content="article">
  110. {% if author != "" %}
  111. <meta property="og:article:author" content="{{ author }}">
  112. {% endif %}
  113. <meta property="og:article:published_time" content="{{ page.date | date_to_xmlschema }}">
  114. <meta property="og:url" content="{{ page.url | absolute_url }}">
  115. <link rel="canonical" href="{{ page.url | absolute_url }}">
  116. {% else %}
  117. <meta property="og:type" content="website">
  118. <meta property="og:url" content="{{ page.url | absolute_url | strip_index }}">
  119. <link rel="canonical" href="{{ page.url | absolute_url | strip_index }}">
  120. {% endif %}
  121. {% if img != "" and img != site.avatar %}
  122. <meta name="twitter:card" content="summary_large_image">
  123. {% else %}
  124. <meta name="twitter:card" content="summary">
  125. {% endif %}
  126. <meta name="twitter:site" content="@{{ site.social-network-links.twitter }}">
  127. <meta name="twitter:creator" content="@{{ site.social-network-links.twitter }}">
  128. <meta property="twitter:title" content="{{ title }}">
  129. <meta property="twitter:description" content="{{ description }}">
  130. {% if img != "" %}
  131. <meta name="twitter:image" content="{{ img | absolute_url }}">
  132. {% endif %}
  133. {% include matomo.html %}
  134. {% if page.comments and site.staticman.repository and site.staticman.branch %}
  135. <link rel="stylesheet" href="{{ "/assets/css/staticman.css" | relative_url }}">
  136. {% endif %}
  137. {% assign favicon_exists = site.static_files | where: "path", "/favicon.ico" | size %}
  138. {% if favicon_exists == 1 %}
  139. <link rel="icon" href="{{ '/favicon.ico' | relative_url }}" />
  140. {% endif %}
  141. {% if page.head-extra %}
  142. {% for file in page.head-extra %}
  143. {% include {{ file }} %}
  144. {% endfor %}
  145. {% endif %}
  146. </head>