julienmonnerie/site/snippets/metadata.twig

58 lines
2 KiB
Twig
Raw Normal View History

2022-07-07 16:04:23 +02:00
{# Basic metadata #}
2022-06-17 17:51:59 +02:00
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
2022-07-07 16:04:23 +02:00
{# Schema #}
2022-06-17 17:51:59 +02:00
<style itemscope itemtype="https://schema.org/WebSite" itemref="schema_name schema_description schema_image"></style>
2022-07-07 16:04:23 +02:00
{# Title #}
2022-11-25 14:17:23 +01:00
<title>{{ site.title }}</title>
<meta id="schema_name" itemprop="name" content="{{ site.title }}">
2022-06-17 17:51:59 +02:00
2022-07-07 16:04:23 +02:00
{# Description #}
2022-11-25 14:17:23 +01:00
{% if site.meta_description is not empty %}
<meta name="description" content="{{ site.meta_description }}">
<meta id="schema_description" itemprop="description" content="{{ site.meta_description }}">
2022-06-17 17:51:59 +02:00
{% endif %}
2022-07-07 16:04:23 +02:00
{# Canonical URL #}
2022-06-17 17:51:59 +02:00
<link rel="canonical" href="{{ page.url }}">
2022-07-07 16:04:23 +02:00
{# Author #}
2022-06-17 17:51:59 +02:00
<meta name="author" content="{{ site.title }}">
2022-07-07 16:04:23 +02:00
{# Date #}
2022-06-17 17:51:59 +02:00
<meta name="date" content="{{ page.modified('Y-m-d') }}">
2022-07-07 16:04:23 +02:00
{# Image #}
2022-11-25 14:17:23 +01:00
{% if site.meta_image is not empty %}
2025-05-01 15:26:33 +02:00
<meta id="schema_image" itemprop="image" content="{{ site.meta_image.toFile.url }}">
2022-06-17 17:51:59 +02:00
{% endif %}
{% if page.template != 'error' %}
2022-09-09 15:26:04 +02:00
{# Open Graph #}
2022-11-25 14:17:23 +01:00
<meta property="og:title" content="{{ site.title }}">
{% if site.meta_description is not empty %}
<meta property="og:description" content="{{ site.meta_description }}">
2022-09-09 15:26:04 +02:00
{% endif %}
2022-11-25 14:17:23 +01:00
{% if site.meta_image is not empty %}
2025-05-01 15:26:33 +02:00
<meta property="og:image" content="{{ site.meta_image.toFile.crop(1200, 675).url }}">
2022-09-09 15:26:04 +02:00
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="675">
{% endif %}
<meta property="og:url" content="{{ page.url }}">
2022-11-25 14:17:23 +01:00
<meta property="og:type" content="{{ site.og_type }}">
2022-06-17 17:51:59 +02:00
2022-09-09 15:26:04 +02:00
{# Twitter Card #}
2022-11-25 14:17:23 +01:00
<meta name="twitter:card" content="{{ site.twitter_card_type.value }}">
<meta name="twitter:title" content="{{ site.title }}">
{% if site.meta_description is not empty %}
<meta name="twitter:description" content="{{ site.meta_description }}">
2022-09-09 15:26:04 +02:00
{% endif %}
2022-11-25 14:17:23 +01:00
{% if site.meta_image is not empty %}
2025-05-01 15:26:33 +02:00
<meta name="twitter:image" content="{{ site.meta_image.toFile.crop(1200, 675).url }}">
2022-09-09 15:26:04 +02:00
{% endif %}
2022-06-17 17:51:59 +02:00
{% endif %}