head.ejs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <%
  2. var separator = theme.title_join_string || theme.tab_title_separator
  3. var title = page.title ? [page.title, config.title].join(separator) : config.title
  4. var keywords = page.keywords || config.keywords
  5. if (keywords instanceof Array) {
  6. keywords = keywords.join(',')
  7. }
  8. var description = page.description || page.excerpt || (is_post() && page.content) || config.description
  9. if (description) {
  10. description = strip_html(description).substring(0, 200).trim().replace(/\n/g, ' ')
  11. }
  12. var ogImage = page.og_img || page.index_img
  13. var ogConfig = Object.assign({ image: ogImage && url_for(ogImage) }, theme.open_graph)
  14. %>
  15. <head>
  16. <meta charset="UTF-8">
  17. <link rel="apple-touch-icon" sizes="76x76" href="<%= url_for(theme.apple_touch_icon) %>">
  18. <link rel="icon" href="<%= url_for(theme.favicon) %>">
  19. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  20. <meta http-equiv="x-ua-compatible" content="ie=edge">
  21. <% if (theme.force_https) { %>
  22. <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
  23. <% } %>
  24. <meta name="theme-color" content="<%= theme.color.navbar_bg_color %>">
  25. <meta name="author" content="<%= page.author || config.author %>">
  26. <meta name="keywords" content="<%= keywords %>">
  27. <% if (theme.open_graph.enable) { %>
  28. <%- open_graph(ogConfig) %>
  29. <% } else { %>
  30. <meta name="description" content="<%= description %>">
  31. <% } %>
  32. <% if ((theme.post.meta.views.enable && theme.post.meta.views.source === 'busuanzi')
  33. || (theme.footer.statistics.enable && theme.footer.statistics.source === 'busuanzi')) { %>
  34. <meta name="referrer" content="no-referrer-when-downgrade">
  35. <% } %>
  36. <% if (theme.custom_head) { %>
  37. <%- theme.custom_head %>
  38. <% } %>
  39. <title><%= title %></title>
  40. <%- partial('_partials/css.ejs') %>
  41. <%- export_config() %>
  42. <%- js_ex(theme.static_prefix.internal_js, 'utils.js') %>
  43. <%- js_ex(theme.static_prefix.internal_js, 'color-schema.js') %>
  44. <%- partial('_partials/plugins/analytics.ejs') %>
  45. <%- inject_point('head') %>
  46. <%- autoCanonical(config, page) %>
  47. </head>