From 2ac4034754fb87a1346c37a997ee7de044198560 Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Fri, 19 Jan 2018 12:15:47 -0500 Subject: [PATCH] Refactor base layouts - DRY up layouts by creating `default` - Use relative and absolute URL filters to fix links --- _includes/head-feed.html | 1 + _includes/head-seo.html | 1 + _includes/head.html | 85 +++++++++++++++++---------------------- _includes/navigation.html | 10 ++--- _includes/open-graph.html | 19 --------- _includes/scripts.html | 6 +++ _includes/skip-links.html | 0 _layouts/default.html | 26 ++++++++++++ _layouts/page.html | 28 ++----------- _layouts/post.html | 36 ++++------------- 10 files changed, 88 insertions(+), 124 deletions(-) create mode 100644 _includes/head-feed.html create mode 100644 _includes/head-seo.html delete mode 100644 _includes/open-graph.html create mode 100644 _includes/skip-links.html create mode 100644 _layouts/default.html diff --git a/_includes/head-feed.html b/_includes/head-feed.html new file mode 100644 index 00000000000..93e3cc27daa --- /dev/null +++ b/_includes/head-feed.html @@ -0,0 +1 @@ + diff --git a/_includes/head-seo.html b/_includes/head-seo.html new file mode 100644 index 00000000000..32d56102089 --- /dev/null +++ b/_includes/head-seo.html @@ -0,0 +1 @@ +{% seo %} diff --git a/_includes/head.html b/_includes/head.html index f2b44b0987e..e0dffd8e752 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -1,48 +1,37 @@ - -{% if page.title %}{{ page.title }} – {% endif %}{{ site.title }} -{% if page.excerpt %}{% endif %} -{% if page.tags %}{% endif %} -{% if page.author %} - {% assign author = site.data.authors[page.author] %}{% else %}{% assign author = site.owner %} -{% endif %} - -{% include open-graph.html %} - -{% if site.owner.google.verify %} -{% endif %} -{% if site.owner.bing-verify %}{% endif %} - -{% capture canonical %}{{ site.url }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{{ page.url | remove:'index.html' | strip_slash }}{% endif %}{% endcapture %} - - - - - - - - - - - - - - - -{% if site.mathjax == true %} - - -{% endif %} - - - - - - - - - - - - - - + + + + + {% if site.owner.google.verify %}{% endif %} + {% if site.owner.bing-verify %}{% endif %} + + {% if site.plugins contains 'jekyll-seo-tag' or site.gems contains 'jekyll-seo-tag' %} + {% comment %} + Add metadata for search engines and social networks if jekyll-seo-tag plugin is enabled + {% endcomment %} + {% include head-seo.html %} + {% else %} + {% if page.title %}{{ page.title | escape }}{% else %}{{ site.title | escape }}{% endif %} + + + {% endif %} + + + + + {% if site.data.theme.google_fonts %} + + {% endif %} + + {% if site.plugins contains 'jekyll-feed' or site.gems contains 'jekyll-feed'%} + {% comment %} + Add Atom feed link if jekyll-feed plugin is enabled + {% endcomment %} + {% include head-feed.html %} + {% endif %} + diff --git a/_includes/navigation.html b/_includes/navigation.html index a8ec79167ce..26f69ed9e34 100644 --- a/_includes/navigation.html +++ b/_includes/navigation.html @@ -2,12 +2,12 @@ diff --git a/_includes/open-graph.html b/_includes/open-graph.html deleted file mode 100644 index 74dd2bd1a08..00000000000 --- a/_includes/open-graph.html +++ /dev/null @@ -1,19 +0,0 @@ - - -{% if page.excerpt %}{% endif %} -{% if site.owner.twitter %}{% endif %} -{% if author.twitter %}{% endif %} -{% if page.image.feature %} - - -{% else %} - - -{% endif %} - - - - -{% if page.excerpt %}{% endif %} - - \ No newline at end of file diff --git a/_includes/scripts.html b/_includes/scripts.html index 4b7606f79b9..67ff14c6883 100644 --- a/_includes/scripts.html +++ b/_includes/scripts.html @@ -22,3 +22,9 @@ })(); {% endif %} + +{% if site.mathjax == true %} + + +{% endif %} + diff --git a/_includes/skip-links.html b/_includes/skip-links.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/_layouts/default.html b/_layouts/default.html new file mode 100644 index 00000000000..45ee77015fd --- /dev/null +++ b/_layouts/default.html @@ -0,0 +1,26 @@ + + + + {% include head.html %} + + + {% include skip-links.html %} + {% include navigation.html %} + + {{ content }} + + + + {% include scripts.html %} + + + diff --git a/_layouts/page.html b/_layouts/page.html index a29355f24d9..1ad2194d292 100644 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -1,19 +1,10 @@ - - - - - - -{% include head.html %} - - - - -{% include navigation.html %} +--- +layout: default +---
- {% if page.image.feature %}{{ page.title }}{% if page.image.credit %}

Photo Credit: {{ page.image.credit }}

{% endif %}{% endif %} + {% if page.image.feature %}{{ page.title }}{% if page.image.credit %}

Photo Credit: {{ page.image.credit }}

{% endif %}{% endif %}

{% if page.headline %}{{ page.headline }}{% else %}{{ page.title }}{% endif %}

@@ -24,14 +15,3 @@

{% if page.headline %}{{ page.headline }}{% else %}{{ pa

- - - -{% include scripts.html %} - - - diff --git a/_layouts/post.html b/_layouts/post.html index dc62b60ec3b..8e8b9820887 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -1,23 +1,14 @@ - - - - - - -{% include head.html %} - - - - -{% include navigation.html %} +--- +layout: default +---
- {% if page.image.feature %}{{ page.title }}{% if page.image.credit %}

Image credit: {{ page.image.credit }}

{% endif %}{% endif %} + {% if page.image.feature %}{{ page.title }}{% if page.image.credit %}

Image credit: {{ page.image.credit }}

{% endif %}{% endif %}
{% if page.link %}

{% if page.headline %}{{ page.headline }}{% else %}{{ page.title }}{% endif %}

@@ -32,7 +23,7 @@

{% if page.headline %}{{ page.headline }}{% else %}{{ pa {% if author.avatar contains 'http' %} {{ author.name }} bio photo {% elsif author.avatar %} - {{ author.name }} bio photo + {{ author.name }} bio photo {% endif %} By {{ author.name }} @@ -51,22 +42,11 @@

{% if page.headline %}{{ page.headline }}{% else %}{{ pa

- - - -{% include scripts.html %} - - -