From bdd140b2de73eb74168cac3730eee7c9a26402e3 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 30 Jun 2021 08:00:00 +0100 Subject: [PATCH] Add metatags --- app/config/sculpin_site.yml | 4 ++++ source/_layouts/app.html.twig | 3 ++- source/_pages/index.md | 1 + source/_partials/meta.html.twig | 42 ++++++++++++++++++++++++++------- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/app/config/sculpin_site.yml b/app/config/sculpin_site.yml index 85f634e7..bee3a519 100644 --- a/app/config/sculpin_site.yml +++ b/app/config/sculpin_site.yml @@ -1,6 +1,10 @@ name: Oliver Davies +description: Lead Software Developer. Freelancer. Drupal and PHP specialist. locale: en-GB +avatar: + url: '/sites/default/files/images/me-precedent.jpg' + drupalorg: name: opdavies url: 'https://www.drupal.org/u/%drupalorg.name%' diff --git a/source/_layouts/app.html.twig b/source/_layouts/app.html.twig index ac79b74f..74a8df09 100644 --- a/source/_layouts/app.html.twig +++ b/source/_layouts/app.html.twig @@ -4,7 +4,8 @@ - {% include 'meta' %} + + {% include 'meta' with { page, site } only %} {% block body %}{% endblock %} diff --git a/source/_pages/index.md b/source/_pages/index.md index 90f0aa90..194d658d 100644 --- a/source/_pages/index.md +++ b/source/_pages/index.md @@ -1,6 +1,7 @@ --- title: Oliver Davies - UK based PHP Developer and Drupal specialist permalink: / +is_front: true ---
diff --git a/source/_partials/meta.html.twig b/source/_partials/meta.html.twig index 08ff30d5..9a8e125a 100644 --- a/source/_partials/meta.html.twig +++ b/source/_partials/meta.html.twig @@ -1,10 +1,12 @@ -{{ site.name }} +{% set currentUrl = site.url ~ page.url|trim('/', 'right') %} +{% set pageTitle = page.title %} +{% set siteTitle = site.name %} - - - +{% if not page.is_front %} + {% set pageTitle = [page.title, '-', site.name]|join(' ') %} +{% endif %} -{% set metaDescription = null %} +{% set metaDescription = site.description %} {% if page.meta.description %} {% set metaDescription = page.meta.description|e('html') %} {% elseif page.description %} @@ -13,6 +15,30 @@ {% set metaDescription = page.excerpt|e('html') %} {% endif %} -{% if metaDescription %} - -{% endif %} +{% set metaImage = [ + site.url, + '/', + page.meta.image ?? site.avatar.url, +]|join %} + +{{ pageTitle }} + + + + + + + + + + + + + + + + + + + +