|
| 1 | +{#- |
| 2 | + Theme override: extends Zensical's base template to add the SEO tags it |
| 3 | + doesn't emit on its own. Wired up by custom_dir in zensical.toml. |
| 4 | +-#} |
| 5 | +{% extends "base.html" %} |
| 6 | + |
| 7 | +{#- page.is_homepage is never set by Zensical, so compare URLs instead. -#} |
| 8 | +{% set is_homepage = page.canonical_url == config.site_url %} |
| 9 | + |
| 10 | +{#- The nav labels the homepage "Home", which would otherwise become its title. -#} |
| 11 | +{% block htmltitle %} |
| 12 | + {% if is_homepage %} |
| 13 | + <title>{{ config.site_name }}</title> |
| 14 | + {% else %} |
| 15 | + {{ super() }} |
| 16 | + {% endif %} |
| 17 | +{% endblock %} |
| 18 | + |
| 19 | +{% block extrahead %} |
| 20 | + {% if is_homepage %} |
| 21 | + {% set title = config.site_name %} |
| 22 | + {% elif page.meta and page.meta.title %} |
| 23 | + {% set title = page.meta.title %} |
| 24 | + {% elif page.title %} |
| 25 | + {% set title = page.title | striptags %} |
| 26 | + {% else %} |
| 27 | + {% set title = config.site_name %} |
| 28 | + {% endif %} |
| 29 | + {% if page.meta and page.meta.description %} |
| 30 | + {% set description = page.meta.description %} |
| 31 | + {% else %} |
| 32 | + {% set description = config.site_description %} |
| 33 | + {% endif %} |
| 34 | + {% set is_post = page.meta and page.meta.date %} |
| 35 | + |
| 36 | + {#- Open Graph: the preview card Discord, Slack and friends render for a link. -#} |
| 37 | + <meta property="og:type" content="{{ 'article' if is_post else 'website' }}"> |
| 38 | + <meta property="og:site_name" content="{{ config.site_name }}"> |
| 39 | + <meta property="og:title" content="{{ title }}"> |
| 40 | + <meta property="og:description" content="{{ description }}"> |
| 41 | + {% if page.canonical_url %} |
| 42 | + <meta property="og:url" content="{{ page.canonical_url }}"> |
| 43 | + {% endif %} |
| 44 | + {% if is_post %} |
| 45 | + <meta property="article:published_time" content="{{ page.meta.date }}"> |
| 46 | + {% endif %} |
| 47 | + <meta name="twitter:card" content="summary"> |
| 48 | + |
| 49 | + {#- Tells Google the site's name, shown above results instead of the bare domain. -#} |
| 50 | + {% if is_homepage %} |
| 51 | + <script type="application/ld+json"> |
| 52 | + { |
| 53 | + "@context": "https://schema.org", |
| 54 | + "@type": "WebSite", |
| 55 | + "name": {{ config.site_name | tojson }}, |
| 56 | + "url": {{ config.site_url | tojson }} |
| 57 | + } |
| 58 | + </script> |
| 59 | + {% endif %} |
| 60 | +{% endblock %} |
0 commit comments