From 521fa609baa35efc99dd594b892d51ad5eea7d87 Mon Sep 17 00:00:00 2001 From: Niall Beard Date: Fri, 22 Jul 2016 11:17:34 +0100 Subject: [PATCH 1/5] Added lesson metadata and schema.org JSON-LD rendering --- _config.yml | 13 +++++++++++++ _includes/schema_org.html | 39 +++++++++++++++++++++++++++++++++++++++ _layouts/lesson.html | 1 + 3 files changed, 53 insertions(+) create mode 100644 _includes/schema_org.html diff --git a/_config.yml b/_config.yml index e4e21ca6..3cda65e6 100644 --- a/_config.yml +++ b/_config.yml @@ -12,6 +12,19 @@ carpentry: "cp" # Overall title for pages. title: "Lesson Title" +#Metadata +# Here you can add metadata to describe your lesson so that people and search engines can understand what it's about. Please try to use fields from the Schema.org CreativeWork type - https://schema.org/CreativeWork +description: "This is the template description. Keep me brief (2-3 sentences)" +keywords: GitHub, Forking, Collaborative # see: https://schema.org/keywords +audience: [PostDoc students, Early Career Researchers] # see: https://schema.org/audience +license: "https://creativecommons.org/licenses/by/3.0/" # see: schema.org/license +author: [Homer Simpson, Ned Flanders] # see: https://schema.org/author +contributor: [Barney Gumball, Dr Nick Riviera] # see: https://schema.org/contributor +timeRequired: "1 hour" # see: https://schema.org/timeRequired +learningResourceType: "lesson plan" # see: https://schema.org/learningResourceType +citation: "How to cite a Training Material, John Smith et al, 2015" # see: https://schema.org/citation +dateCreated: 2016-05-01 + #------------------------------------------------------------ # Generic settings (should not need to change). #------------------------------------------------------------ diff --git a/_includes/schema_org.html b/_includes/schema_org.html new file mode 100644 index 00000000..0a196378 --- /dev/null +++ b/_includes/schema_org.html @@ -0,0 +1,39 @@ + + \ No newline at end of file diff --git a/_layouts/lesson.html b/_layouts/lesson.html index f3f7300e..ffacb9fc 100644 --- a/_layouts/lesson.html +++ b/_layouts/lesson.html @@ -2,6 +2,7 @@ layout: base --- {% include main_title.html %} +{% include schema_org.html %}
{{ content }}
From b13ce0db10bd1dfd6caefdb2572aa8d19be88022 Mon Sep 17 00:00:00 2001 From: Raniere Silva Date: Thu, 2 Aug 2018 08:16:50 +0100 Subject: [PATCH 2/5] Move JSON-LD from _config.yml to _data/lesson.yml --- _config.yml | 16 ---------------- _data/lesson.yml | 15 +++++++++++++++ _includes/episode_navbar.html | 2 +- _includes/favicons.html | 2 +- _includes/main_title.html | 2 +- _includes/schema_org.html | 24 ++++++++++++------------ _layouts/base.html | 3 ++- 7 files changed, 32 insertions(+), 32 deletions(-) create mode 100644 _data/lesson.yml diff --git a/_config.yml b/_config.yml index 3cda65e6..db6b231d 100644 --- a/_config.yml +++ b/_config.yml @@ -9,22 +9,6 @@ # cp: Carpentries (to use for instructor traning for instance) carpentry: "cp" -# Overall title for pages. -title: "Lesson Title" - -#Metadata -# Here you can add metadata to describe your lesson so that people and search engines can understand what it's about. Please try to use fields from the Schema.org CreativeWork type - https://schema.org/CreativeWork -description: "This is the template description. Keep me brief (2-3 sentences)" -keywords: GitHub, Forking, Collaborative # see: https://schema.org/keywords -audience: [PostDoc students, Early Career Researchers] # see: https://schema.org/audience -license: "https://creativecommons.org/licenses/by/3.0/" # see: schema.org/license -author: [Homer Simpson, Ned Flanders] # see: https://schema.org/author -contributor: [Barney Gumball, Dr Nick Riviera] # see: https://schema.org/contributor -timeRequired: "1 hour" # see: https://schema.org/timeRequired -learningResourceType: "lesson plan" # see: https://schema.org/learningResourceType -citation: "How to cite a Training Material, John Smith et al, 2015" # see: https://schema.org/citation -dateCreated: 2016-05-01 - #------------------------------------------------------------ # Generic settings (should not need to change). #------------------------------------------------------------ diff --git a/_data/lesson.yml b/_data/lesson.yml new file mode 100644 index 00000000..b4dfbc3c --- /dev/null +++ b/_data/lesson.yml @@ -0,0 +1,15 @@ +# Overall title for pages. +title: "Lesson Title" + +#Metadata +# Here you can add metadata to describe your lesson so that people and search engines can understand what it's about. Please try to use fields from the Schema.org CreativeWork type - https://schema.org/CreativeWork +description: "This is the template description. Keep me brief (2-3 sentences)" +keywords: GitHub, Forking, Collaborative # see: https://schema.org/keywords +audience: [PostDoc students, Early Career Researchers] # see: https://schema.org/audience +license: "https://creativecommons.org/licenses/by/3.0/" # see: schema.org/license +author: [Homer Simpson, Ned Flanders] # see: https://schema.org/author +contributor: [Barney Gumball, Dr Nick Riviera] # see: https://schema.org/contributor +timeRequired: "1 hour" # see: https://schema.org/timeRequired +learningResourceType: "lesson plan" # see: https://schema.org/learningResourceType +citation: "How to cite a Training Material, John Smith et al, 2015" # see: https://schema.org/citation +dateCreated: 2016-05-01 diff --git a/_includes/episode_navbar.html b/_includes/episode_navbar.html index ea368eba..f20efa2a 100644 --- a/_includes/episode_navbar.html +++ b/_includes/episode_navbar.html @@ -21,7 +21,7 @@

{% if include.episode_navbar_title %} -

{{ site.title }}

+

{{ site.data.lesson.title }}

{% endif %}
diff --git a/_includes/favicons.html b/_includes/favicons.html index 8a50b4d9..159faad3 100644 --- a/_includes/favicons.html +++ b/_includes/favicons.html @@ -24,7 +24,7 @@ - + diff --git a/_includes/main_title.html b/_includes/main_title.html index b08af4a7..4b5fbded 100644 --- a/_includes/main_title.html +++ b/_includes/main_title.html @@ -4,4 +4,4 @@ {% include base_path.html %} -

{{ site.title }}{% if page.title %}: {{ page.title }}{% endif %}

+

{{ site.data.lesson.title }}{% if page.title %}: {{ page.title }}{% endif %}

diff --git a/_includes/schema_org.html b/_includes/schema_org.html index 0a196378..e5c22af9 100644 --- a/_includes/schema_org.html +++ b/_includes/schema_org.html @@ -6,34 +6,34 @@ "@context": "http://schema.org/", "@type": "creativeWork", "genre": "trainingMaterial", - "name": "{{site.title}}", - "description": "{{site.description}}", - "keywords": "{{site.keywords}}", + "name": "{{site.data.lesson.title}}", + "description": "{{site.data.lesson.description}}", + "keywords": "{{site.data.lesson.keywords}}", "audience": [ - {% for audience in site.audience %}{ + {% for audience in site.data.lesson.audience %}{ "@type": "Audience", "name": "{{audience}}" }{% if forloop.last %}{%else%},{%endif%} {% endfor %} ], - "license": "{{site.licence}}", + "license": "{{site.data.lesson.licence}}", "author": [ - {% for author in site.author %}{ + {% for author in site.data.lesson.author %}{ "@type": "Person", "name": "{{author}}" }{% if forloop.last %}{%else%},{%endif%} {% endfor %} ], "contributor": [ - {% for contributor in site.contributor %}{ + {% for contributor in site.data.lesson.contributor %}{ "@type": "Person", "name": "{{contributor}}" }{% if forloop.last %}{%else%},{%endif%} {% endfor %} ], - "timeRequired": "{{site.timeRequired}}", - "learningResourceType": "{{site.learningResourceType}}", - "citation": "{{site.citation}}", - "dateCreated" : "{{site.dateCreated}}" + "timeRequired": "{{site.data.lesson.timeRequired}}", + "learningResourceType": "{{site.data.lesson.learningResourceType}}", + "citation": "{{site.data.lesson.citation}}", + "dateCreated" : "{{site.data.lesson.dateCreated}}" } - \ No newline at end of file + diff --git a/_layouts/base.html b/_layouts/base.html index 34959d54..613d1820 100644 --- a/_layouts/base.html +++ b/_layouts/base.html @@ -25,7 +25,8 @@ - {{ site.title }}{% if page.title %}: {{ page.title }}{% endif %} + {{ site.data.lesson.title }}{% if page.title %}: {{ page.title }}{% endif %} +{% include schema_org.html %} From 0e2162914a3763efd6b7a6612a92c37975d7dcad Mon Sep 17 00:00:00 2001 From: Raniere Silva Date: Fri, 8 Feb 2019 10:15:12 +0000 Subject: [PATCH 3/5] Add fall back to as suggested by @maxim-belkin --- _layouts/base.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/_layouts/base.html b/_layouts/base.html index 613d1820..ec98af0d 100644 --- a/_layouts/base.html +++ b/_layouts/base.html @@ -25,8 +25,16 @@ - {{ site.data.lesson.title }}{% if page.title %}: {{ page.title }}{% endif %} -{% include schema_org.html %} + + {% if site.data.lesson %} + {{ site.data.lesson.title }} + {% else %} + {{ site.title }} {% comment %} Fall back for lessons that doesn't have schema_org %{endcomment %} + {% endif %} + {% if page.title %}: + {{ page.title }}{% endif %} + + {% include schema_org.html %} From 40f1dfa82aa6b78c276543229a4db7b7239da142 Mon Sep 17 00:00:00 2001 From: Raniere Silva Date: Fri, 8 Feb 2019 10:19:41 +0000 Subject: [PATCH 4/5] Remove dateCreate from lesson.yml Use the time that the lesson is build on GitHub --- _data/lesson.yml | 1 - _includes/schema_org.html | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/_data/lesson.yml b/_data/lesson.yml index b4dfbc3c..519a80cc 100644 --- a/_data/lesson.yml +++ b/_data/lesson.yml @@ -12,4 +12,3 @@ contributor: [Barney Gumball, Dr Nick Riviera] # see: https://s timeRequired: "1 hour" # see: https://schema.org/timeRequired learningResourceType: "lesson plan" # see: https://schema.org/learningResourceType citation: "How to cite a Training Material, John Smith et al, 2015" # see: https://schema.org/citation -dateCreated: 2016-05-01 diff --git a/_includes/schema_org.html b/_includes/schema_org.html index e5c22af9..6422df45 100644 --- a/_includes/schema_org.html +++ b/_includes/schema_org.html @@ -34,6 +34,6 @@ "timeRequired": "{{site.data.lesson.timeRequired}}", "learningResourceType": "{{site.data.lesson.learningResourceType}}", "citation": "{{site.data.lesson.citation}}", - "dateCreated" : "{{site.data.lesson.dateCreated}}" + "dateCreated" : "{{ "now" | date: "%Y-%m-%d" }}" } From 29d8bdaa97ad3ee6040544d914ee6e53be000646 Mon Sep 17 00:00:00 2001 From: Raniere Silva Date: Fri, 8 Feb 2019 10:27:26 +0000 Subject: [PATCH 5/5] Use "-" list instead of "[]" list --- _data/lesson.yml | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/_data/lesson.yml b/_data/lesson.yml index 519a80cc..e055899e 100644 --- a/_data/lesson.yml +++ b/_data/lesson.yml @@ -1,14 +1,25 @@ # Overall title for pages. title: "Lesson Title" -#Metadata -# Here you can add metadata to describe your lesson so that people and search engines can understand what it's about. Please try to use fields from the Schema.org CreativeWork type - https://schema.org/CreativeWork +# Metadata +# Here you can add metadata to describe your lesson +# so that people and search engines can understand what it's about. +# Please try to use fields from the Schema.org CreativeWork type - https://schema.org/CreativeWork description: "This is the template description. Keep me brief (2-3 sentences)" -keywords: GitHub, Forking, Collaborative # see: https://schema.org/keywords -audience: [PostDoc students, Early Career Researchers] # see: https://schema.org/audience +keywords: # see: https://schema.org/keywords + - GitHub + - Forking + - Collaborative +audience: # see: https://schema.org/audience + - PostDoc students + - Early Career Researchers license: "https://creativecommons.org/licenses/by/3.0/" # see: schema.org/license -author: [Homer Simpson, Ned Flanders] # see: https://schema.org/author -contributor: [Barney Gumball, Dr Nick Riviera] # see: https://schema.org/contributor +author: # see: https://schema.org/author + - Homer Simpson + - Ned Flanders +contributor: # see: https://schema.org/contributor + - Barney Gumball + - Dr Nick Riviera timeRequired: "1 hour" # see: https://schema.org/timeRequired learningResourceType: "lesson plan" # see: https://schema.org/learningResourceType citation: "How to cite a Training Material, John Smith et al, 2015" # see: https://schema.org/citation