Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added schema.org JSON-LD to lesson #226

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
# cp: Carpentries (to use for instructor traning for instance)
carpentry: "cp"

# Overall title for pages.
title: "Lesson Title"

#------------------------------------------------------------
# Generic settings (should not need to change).
#------------------------------------------------------------
Expand Down
25 changes: 25 additions & 0 deletions _data/lesson.yml
Original file line number Diff line number Diff line change
@@ -0,0 +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
description: "This is the template description. Keep me brief (2-3 sentences)"
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: # 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
2 changes: 1 addition & 1 deletion _includes/episode_navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h3 class="text-left">
</div>
<div class="col-xs-10">
{% if include.episode_navbar_title %}
<h3 class="maintitle"><a href="{{ relative_root_path }}/">{{ site.title }}</a></h3>
<h3 class="maintitle"><a href="{{ relative_root_path }}/">{{ site.data.lesson.title }}</a></h3>
{% endif %}
</div>
<div class="col-xs-1">
Expand Down
2 changes: 1 addition & 1 deletion _includes/favicons.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<link rel="icon" type="image/png" href="{{ favicon_url }}/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="{{ favicon_url }}/favicon-16x16.png" sizes="16x16" />
<link rel="icon" type="image/png" href="{{ favicon_url }}/favicon-128.png" sizes="128x128" />
<meta name="application-name" content="{{ carpentry }} - {{ site.title }}"/>
<meta name="application-name" content="{{ carpentry }} - {{ site.data.lesson.title }}"/>
<meta name="msapplication-TileColor" content="#FFFFFF" />
<meta name="msapplication-TileImage" content="{{ favicon_url }}/mstile-144x144.png" />
<meta name="msapplication-square70x70logo" content="{{ favicon_url }}/mstile-70x70.png" />
Expand Down
2 changes: 1 addition & 1 deletion _includes/main_title.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

{% include base_path.html %}

<h1 class="maintitle"><a href="{{ relative_root_path }}{% link index.md %}">{{ site.title }}</a>{% if page.title %}: {{ page.title }}{% endif %}</h1>
<h1 class="maintitle"><a href="{{ relative_root_path }}{% link index.md %}">{{ site.data.lesson.title }}</a>{% if page.title %}: {{ page.title }}{% endif %}</h1>
39 changes: 39 additions & 0 deletions _includes/schema_org.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!-- Schema.org annotations in JSON-LD for a CreativeWork type.
Variables should be declared in the .md file
For full list of available attributes see https://schema.org/CreativeWork -->
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "creativeWork",
"genre": "trainingMaterial",
"name": "{{site.data.lesson.title}}",
"description": "{{site.data.lesson.description}}",
"keywords": "{{site.data.lesson.keywords}}",
"audience": [
{% for audience in site.data.lesson.audience %}{
"@type": "Audience",
"name": "{{audience}}"
}{% if forloop.last %}{%else%},{%endif%}
{% endfor %}
],
"license": "{{site.data.lesson.licence}}",
"author": [
{% for author in site.data.lesson.author %}{
"@type": "Person",
"name": "{{author}}"
}{% if forloop.last %}{%else%},{%endif%}
{% endfor %}
],
"contributor": [
{% for contributor in site.data.lesson.contributor %}{
"@type": "Person",
"name": "{{contributor}}"
}{% if forloop.last %}{%else%},{%endif%}
{% endfor %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Author and contributor are vague terms as lessons are being developed by the community. There is an initial author and then there is an army of contributors. Giving proper credits is important, but it should probably happen on a separate page

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The distinction between author and contributor:
Author: Preparation, creation and/or presentation of the published work, specifically writing the initial draft;
Contributor: a critical review, commentary or revision;
We need this information in metadata. We may reuse it to display on the separate page.

],
"timeRequired": "{{site.data.lesson.timeRequired}}",
"learningResourceType": "{{site.data.lesson.learningResourceType}}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is it different from genre above ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Genre" is replaced by "About" now. LerningResourcesType, that can be video lecture, e-learning module, handout etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkuzak @njall DoesLerningResourcesType a close list of options?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it's an open list. More info here: https://schema.org/learningResourceType

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's an open list for now. I have been tempted to create a vocab but making and maintaining an exhaustive list would be an overhead to big for its benefit right now.

"citation": "{{site.data.lesson.citation}}",
"dateCreated" : "{{ "now" | date: "%Y-%m-%d" }}"
}
</script>
11 changes: 10 additions & 1 deletion _layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<title>{{ site.title }}{% if page.title %}: {{ page.title }}{% endif %}</title>
<title>
{% 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 %}
</title>
{% include schema_org.html %}
</head>
<body>

Expand Down
1 change: 1 addition & 0 deletions _layouts/lesson.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
layout: base
---
{% include main_title.html %}
{% include schema_org.html %}
<article>
{{ content }}
</article>
Expand Down