Skip to content

Commit

Permalink
Updates for structured content
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHammond committed Jun 20, 2024
1 parent bad713b commit b72ac82
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 48 deletions.
20 changes: 10 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ GEM
public_suffix (>= 2.0.2, < 6.0)
bigdecimal (3.1.8)
colorator (1.1.0)
concurrent-ruby (1.3.1)
concurrent-ruby (1.3.3)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
eventmachine (1.2.7)
ffi (1.16.3)
ffi (1.17.0)
forwardable-extended (2.6.0)
google-protobuf (4.27.0)
google-protobuf (4.27.1)
bigdecimal
rake (>= 13)
http_parser.rb (0.8.0)
Expand Down Expand Up @@ -65,25 +65,25 @@ GEM
mercenary (0.4.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0507)
mime-types-data (3.2024.0604)
objective_elements (1.1.2)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (5.0.5)
public_suffix (5.1.1)
rainbow (3.1.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rexml (3.2.8)
strscan (>= 3.0.9)
rouge (4.2.1)
rexml (3.3.0)
strscan
rouge (4.3.0)
ruby-vips (2.0.17)
ffi (~> 1.9)
safe_yaml (1.0.5)
sass-embedded (1.77.2)
sass-embedded (1.77.5)
google-protobuf (>= 3.25, < 5.0)
rake (>= 13.0.0)
rake (>= 13)
strscan (3.1.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
Expand Down
6 changes: 4 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ authors:
chris:
name: Chris Hammond
display_name: Chris Hammond
first_name: Chris
last_name: Hammond
gravatar: bff097b7cc348bebce39ee1c7694d125
email: christoc@christoc.com
email: jekyll@christoc.com
web: https://www.chrishammond.com
twitter: https://twitter.com/christoc
twitterhandle: christoc
description: "Creator of JekyllExample.com. Read more at <a href=\"https://www.chrishammond.com\">ChrisHammond.com</a>"
description: "Creator of JekyllExample.com. Read more at <a href=\"https://www.chrishammond.com\">Chris Hammond</a>"

# Plugins
plugins:
Expand Down
7 changes: 7 additions & 0 deletions _data/picture.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ presets:
widths: [200, 400, 800, 1600, 2000]
link_source: false

featured:
formats: [original]
widths: [200, 400, 800, 1600, 2000]
link_source: false
attr:
itemprop: image

direct:
markup: direct_url
formats: [original]
Expand Down
2 changes: 1 addition & 1 deletion _includes/postbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h4 class="card-text">{{ post.excerpt | strip_html | truncatewords:30 }}</h4>
{% endif %}
</span>
<span class="author-meta">
<span class="post-name"><a target="_blank" href="{{ author.web }}">{{ author.display_name }}</a></span><br/>
<span class="post-name"><a href="{{ author.web }}">{{ author.display_name }}</a></span><br/>
</span>
{% endif %}
<span class="post-date">{{ post.date | date_to_string }}</span>
Expand Down
45 changes: 45 additions & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,51 @@

<script src="{{ site.baseurl }}/assets/js/jquery.min.js"></script>

{% if page.url != "/" %}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"url": "{{ site.url }}{{ page.url }}",
"name": {{ page.title | jsonify }},
"headline": {{ page.title | jsonify }},
"keywords": {{ page.keywords | join: ',' | jsonify }},
"description": {{ page.excerpt | strip_html | strip_newlines | strip | jsonify }},
"articleBody": {{ page.content | strip_html | jsonify }},
"datePublished": {{ page.date | jsonify }},
"dateModified": {{ page.last_modified_at | default: page.date | jsonify }},
{% if page.author %}
"author": {
"@type": "Person",
"name": {{ author.display_name | jsonify }},
"givenName": {{ author.first_name | jsonify }},
"familyName": {{ author.last_name | jsonify }},
"email": {{ author.email | jsonify }},
"url": "{{ author.web }}"
},
{% endif %}
"publisher": {
"@type": "Organization",
"name": {{ site.title | jsonify }},
"url": "{{ site.url }}",
"logo": {
"@type": "ImageObject",
"width": 32,
"height": 32,
"url": "{{ site.url }}/{{ site.favicon }}"
}
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{ site.url }}/{{ page.url }}"
},
"image": [
"{{ site.url }}{% if page.image %}{% picture direct {{ page.image }} %}{% else %}{{ site.header-img }}{% endif %}"
]
}
</script>
{% endif %}

</head>


Expand Down
45 changes: 10 additions & 35 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{% assign author = site.authors[page.author] %}

<div class="col-md-9 flex-first flex-md-unordered">
<article itemscope itemtype="http://schema.org/BlogPosting">
<article itemscope itemtype="https://schema.org/BlogPosting">
<div class="mainheading">
<header>
<!-- Post Title -->
Expand All @@ -30,7 +30,8 @@ <h1 class="posttitle" itemprop="headline">{{ page.title }}</h1>
<!-- Post Date -->
<div style="float:right">
<small>
<span class="post-date" style="text-align:right">Posted: <time class="post-date" datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">{{ page.date | date: "%b %-d, %Y %H:%M" }}</time>
<span class="post-date" style="text-align:right">Posted:
<time class="post-date" datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">{{ page.date | date: "%b %-d, %Y %H:%M" }}</time>
<br/>
{% if page.last_modified_at %}
(Updated: <time datetime="{{ page.last_modified_at | date_to_xmlschema }}" itemprop="dateModified">{{ page.last_modified_at | date: "%b %-d, %Y %H:%M" }}</time>)
Expand All @@ -43,9 +44,8 @@ <h1 class="posttitle" itemprop="headline">{{ page.title }}</h1>
{% if page.author %}
<div class="row post-top-meta">
<div class="col-xs-12 col-md-9 col-lg-10 text-center text-md-left">
<div itemtype="http://schema.org/Person">
By: <a class="link-dark" href="{{ author.web }}" itemprop="sameAs"><span itemprop="name">{{ author.display_name }}</span></a><a href="{{ author.twitter }}" class="btn follow" itemprop="sameAs">Follow</a>
</div>
By: <a class="link-dark" href="{{ author.web }}">{{ author.display_name }}</a>
<a href="{{ author.twitter }}" class="btn follow">Follow</a>
</div>
</div>
{% endif %}
Expand All @@ -60,12 +60,12 @@ <h1 class="posttitle" itemprop="headline">{{ page.title }}</h1>

<!-- Post Featured Image -->
{% if page.image %}
{% picture {{ page.image }} class="featured-image img-fluid lazyimg" --alt {{ page.title}} %}
{% picture featured {{ page.image }} class="featured-image img-fluid lazyimg" itemprop="image" --alt {{ page.title}} %}
{% endif %}
<!-- End Featured Image -->

<!-- Post Content -->
<div class="article-post">
<div class="article-post" itemprop="articleBody">
<!-- Toc if any -->
{% if page.toc %}
{% if page.beforetoc %}
Expand All @@ -91,7 +91,7 @@ <h3 class="font-weight-bold">Summary</h3>
<!-- Author Box -->
{% if page.author %}
<div class="row post-top-meta">
<div class="col-xs-12 col-md-9 col-lg-10 text-center text-md-left">
<div class="col-xs-12 col-md-12 col-lg-12 text-center text-md-left" itemscope itemprop="author" itemtype="https://schema.org/Person">
<h3>About the Author:</h3>
<div class="col-xs-12 col-md-3 col-lg-2 text-center text-md-left mb-4 mb-md-0">
{% if author.avatar %}
Expand All @@ -100,8 +100,8 @@ <h3>About the Author:</h3>
<img class="author-thumb" src="https://www.gravatar.com/avatar/{{ author.gravatar }}?s=250&d=mm&r=x" alt="{{ author.display_name }}">
{% endif %}
</div>
<div class="col-xs-12 col-md-9 col-lg-10 text-center text-md-left" itemprop="author" itemtype="http://schema.org/Person">
<a class="link-dark" href="{{ author.web }}" itemprop="sameAs"><span itemprop="name">{{ author.display_name }}</span></a><a href="{{ author.twitter }}" class="btn follow" itemprop="sameAs">Follow</a>
<div class="col-xs-12 col-md-9 col-lg-10 text-center text-md-left">
<a class="link-dark" href="{{ author.web }}" itemprop="url"><div itemprop="name">{{ author.display_name }}</div></a><a href="{{ author.twitter }}" class="btn follow">Follow</a>
</div>
<span class="author-description" itemprop="description">{{ author.description }}</span>
</div>
Expand Down Expand Up @@ -171,28 +171,3 @@ <h4><small><a href="/category">Categories:</a></small></h4>
<!--End Comments
================================================== -->

<!-- Review with LD-JSON, adapt it for your needs if you like, but make sure you test the generated HTML source code first:
https://search.google.com/structured-data/testing-tool/u/0/
================================================== -->
{% if page.rating %}
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Review",
"itemReviewed": {
"@type": "Thing",
"name": "{{ page.title }}"
},
"author": {
"@type": "Person",
"name": "{{ author.display_name }}"
},
"datePublished": "{{ page.date | date:"%Y-%m-%d" }}",
"reviewRating": {
"@type": "Rating",
"ratingValue": "{{ page.rating }}",
"bestRating": "5"
}
}
</script>
{% endif %}

0 comments on commit b72ac82

Please sign in to comment.