Add metatags

This commit is contained in:
Oliver Davies 2021-06-30 08:00:00 +01:00
parent f296cccd69
commit bdd140b2de
4 changed files with 41 additions and 9 deletions

View file

@ -1,6 +1,10 @@
name: Oliver Davies name: Oliver Davies
description: Lead Software Developer. Freelancer. Drupal and PHP specialist.
locale: en-GB locale: en-GB
avatar:
url: '/sites/default/files/images/me-precedent.jpg'
drupalorg: drupalorg:
name: opdavies name: opdavies
url: 'https://www.drupal.org/u/%drupalorg.name%' url: 'https://www.drupal.org/u/%drupalorg.name%'

View file

@ -4,7 +4,8 @@
<link type="text/css" rel="stylesheet" href="/build/app.css"/> <link type="text/css" rel="stylesheet" href="/build/app.css"/>
<link rel="preconnect" href="https://fonts.gstatic.com"> <link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,300;0,700;1,300&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,300;0,700;1,300&display=swap" rel="stylesheet">
{% include 'meta' %}
{% include 'meta' with { page, site } only %}
</head> </head>
<body> <body>
{% block body %}{% endblock %} {% block body %}{% endblock %}

View file

@ -1,6 +1,7 @@
--- ---
title: Oliver Davies - UK based PHP Developer and Drupal specialist title: Oliver Davies - UK based PHP Developer and Drupal specialist
permalink: / permalink: /
is_front: true
--- ---
<div class="markdown" markdown="1"> <div class="markdown" markdown="1">

View file

@ -1,10 +1,12 @@
<title>{{ site.name }}</title> {% set currentUrl = site.url ~ page.url|trim('/', 'right') %}
{% set pageTitle = page.title %}
{% set siteTitle = site.name %}
<meta charset="UTF-8"> {% if not page.is_front %}
<meta http-equiv="X-UA-Compatible" content="IE=edge"> {% set pageTitle = [page.title, '-', site.name]|join(' ') %}
<meta name="viewport" content="width=device-width, initial-scale=1"> {% endif %}
{% set metaDescription = null %} {% set metaDescription = site.description %}
{% if page.meta.description %} {% if page.meta.description %}
{% set metaDescription = page.meta.description|e('html') %} {% set metaDescription = page.meta.description|e('html') %}
{% elseif page.description %} {% elseif page.description %}
@ -13,6 +15,30 @@
{% set metaDescription = page.excerpt|e('html') %} {% set metaDescription = page.excerpt|e('html') %}
{% endif %} {% endif %}
{% if metaDescription %} {% set metaImage = [
<meta name="description" content="{{ metaDescription }}"> site.url,
{% endif %} '/',
page.meta.image ?? site.avatar.url,
]|join %}
<title>{{ pageTitle }}</title>
<link rel="canonical" href="{{ currentUrl }}" />
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:site_name" content="{{ siteTitle }}" />
<meta property="og:title" content="{{ pageTitle }}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="{{ currentUrl }}" />
<meta name="description" content="{{ metaDescription }}">
<meta name="og:description" content="{{ metaDescription }}">
<meta name="twitter:description" content="{{ metaDescription }}">
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="{{ metaImage }}" />
<meta name="twitter:image:alt" content="Page image for {{ site.name }}" />
<meta property="og:image" content="{{ metaImage }}" />
<meta property="og:image:alt" content="Page image for {{ site.name }}" />