From 0e516797c3798da9e072c79611c3999a342903ad Mon Sep 17 00:00:00 2001 From: Tim Gerundt Date: Tue, 7 Nov 2017 22:39:34 +0100 Subject: [PATCH] Add `description`, `keywords` and `author` to Front Matter (fix #20) --- docs/01_Features/Front_Matter.md | 16 +++++++++++++--- libs/Format/HTML/ContentPage.php | 1 + templates/layout/00_layout.php | 17 +++++++++++++++-- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/docs/01_Features/Front_Matter.md b/docs/01_Features/Front_Matter.md index b38e10a..d81e7ab 100644 --- a/docs/01_Features/Front_Matter.md +++ b/docs/01_Features/Front_Matter.md @@ -1,18 +1,28 @@ +--- +description: With Front Matter you can customize your pages even further. +keywords: "Front Matter, Customize, Title, Description, Keywords, Author" +author: Daux.io Team +--- + To customize your pages even further, you can add a Front Matter to your files. Front Matter is a block you add at the top of your file and looks like this: --- title: Hallo Welt + keywords: "Hallo, Hello, Welt, World, Erde, Earth" + author: German Daux.io Team date: 12th December 1984 --- ## Changing the title -The only implemented customization right now is the override of the title. - If your file is named "Hello_World_de.md" and your front matter is the one displayed above, you will get a page named "Hallo Welt" +## Search Engine Optimization + +For a better **SEO** experience you can change the `description`, `keywords` and `author` meta tags. + ## For Developers -You can then access this information in each `Content` with `$content->getAttributes()` +You can then access this information in each `Content` with `$content->getAttributes()` or with `$page['attributes']` in a template. diff --git a/libs/Format/HTML/ContentPage.php b/libs/Format/HTML/ContentPage.php index 86fdd9a..52518aa 100644 --- a/libs/Format/HTML/ContentPage.php +++ b/libs/Format/HTML/ContentPage.php @@ -90,6 +90,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage 'breadcrumbs' => $params['html']['breadcrumbs'], 'prev' => $this->file->getPrevious(), 'next' => $this->file->getNext(), + 'attributes' => $this->file->getAttribute() ]; if ($page['breadcrumbs']) { diff --git a/templates/layout/00_layout.php b/templates/layout/00_layout.php index 6c880d0..9fc9f93 100755 --- a/templates/layout/00_layout.php +++ b/templates/layout/00_layout.php @@ -2,8 +2,21 @@ <?= $page['title']; ?> <?= ($page['title'] != $params['title'])? '- ' . $params['title'] : "" ?> - - +\n"; + } elseif (array_key_exists('tagline', $params)) { + echo " \n"; + } + if (array_key_exists('keywords', $page['attributes'])) { + echo " \n"; + } + if (array_key_exists('author', $page['attributes'])) { + echo " \n"; + } elseif (array_key_exists('author', $params)) { + echo " \n"; + } +?>