diff options
| author | Dennis Fink | 2026-07-14 19:38:31 +0200 |
|---|---|---|
| committer | Dennis Fink | 2026-07-14 19:38:31 +0200 |
| commit | 5c65f40bbca27dfb26e75cb027f287b2aa78cd3a (patch) | |
| tree | b21a1d58ee9efde63f7a5a1f7545b2c6bd03a4ef | |
| parent | 206400382a5c111842fd77c8418ad94a85f2da99 (diff) | |
| download | dennisfink.me-5c65f40bbca27dfb26e75cb027f287b2aa78cd3a.tar.gz dennisfink.me-5c65f40bbca27dfb26e75cb027f287b2aa78cd3a.zip | |
Add structured data and microformats
This adds JSON-LD for the site, author, blog, and individual blog posts, so
search engines and other consumers can understand the blog structure more
clearly.
It also adds Microformats2 classes to blog posts and the about page, keeping
machine-readable author, post, category, date, and content data attached to the
visible HTML.
Diffstat (limited to '')
| -rw-r--r-- | assets/static/css/style.css | 4 | ||||
| -rw-r--r-- | assets/static/images/logo.png | bin | 0 -> 32791 bytes | |||
| -rw-r--r-- | content/about/contents.lr | 2 | ||||
| -rw-r--r-- | templates/base.html | 38 | ||||
| -rw-r--r-- | templates/blog-post.html | 53 | ||||
| -rw-r--r-- | templates/blog.html | 7 | ||||
| -rw-r--r-- | templates/includes/blog-json-ld.html | 20 | ||||
| -rw-r--r-- | templates/index.html | 16 | ||||
| -rw-r--r-- | templates/macros/blog.html | 21 |
9 files changed, 138 insertions, 23 deletions
diff --git a/assets/static/css/style.css b/assets/static/css/style.css index ca7443a..f714f3c 100644 --- a/assets/static/css/style.css +++ b/assets/static/css/style.css @@ -278,6 +278,10 @@ SKIP LINK (accessibility) width: 1px; } +.display-none { + display: none !important; +} + /* ============================================================================= SITE HEADER diff --git a/assets/static/images/logo.png b/assets/static/images/logo.png Binary files differnew file mode 100644 index 0000000..a3444ab --- /dev/null +++ b/assets/static/images/logo.png diff --git a/content/about/contents.lr b/content/about/contents.lr index 9a65a65..1fd38ad 100644 --- a/content/about/contents.lr +++ b/content/about/contents.lr @@ -10,7 +10,7 @@ body: Hi, I'm Dennis. Welcome! </p> - + I am originally from Luxembourg and grew up in the south of the country. During my formative years, I spent a lot of time in a local scouts group, which was a diff --git a/templates/base.html b/templates/base.html index e2c145f..024907d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -26,6 +26,44 @@ content="Muted green Hilbert-curve logo beside the words “Still Thinking About It” on a dark blue background"> <meta name="fediverse:creator" content="@me@dennisfink.me"> {% endblock meta %} + {% block json_ld %} + <script type="application/ld+json"> + { + "@context": "https://schema.org", + "@graph": [{ + "@type": "Person", + "@id": "{{ '/about' | url(absolute=True, external=True) }}#person", + "name": "Dennis Fink", + "url": "{{ '/about' | url(absolute=True, external=True) }}", + "sameAs": [ + "https://social.dennisfink.me/@me" + ], + "gender": "Male" + }, { + "@type": "WebSite", + "@id": "{{ '/' | url(absolute=True, external=True) }}#website", + "name": "{{ bag('blog.name') }}", + "url": "{{ '/' | url(absolute=True, external=True) }}", + "author": { + "@id": "{{ '/about' | url(absolute=True, external=True) }}#person" + }, + "publisher": { + "@id": "{{ '/about' | url(absolute=True, external=True) }}#person" + }, + "inLanguage": "en", + "image": { + "@type": "ImageObject", + "@id": "{{ '/' | url(absolute=True, external=True) }}#website-image", + "url": "{{ '/static/images/logo.png' | url(absolute=True, external=True) }}", + "caption": "Still Thinking About It Logo", + "encodingFormat": "image/png", + "width": "800px", + "height": "800px" + } + }] + } + </script> + {% endblock %} {% block styles %} <link rel="stylesheet" type="text/css" diff --git a/templates/blog-post.html b/templates/blog-post.html index 0844351..f5e8bbe 100644 --- a/templates/blog-post.html +++ b/templates/blog-post.html @@ -22,10 +22,63 @@ <meta property="article:tag" content="{{ t }}"> {% endfor %} {% endblock %} + +{% block json_ld %} + {{ super() }} + {% include "includes/blog-json-ld.html" %} + {% if this.publication_date %} + {% set post_url = this | url(absolute=True, external=True) %} + {% set post_id = post_url ~ '#blogposting' %} + {% set person_url = '/about' | url(absolute=True, external=True) %} + {% set person_id = person_url ~ '#person' %} + {% set blog_url = '/blog' | url(absolute=True, external=True) %} + {% set blog_id = blog_url ~ '#blog' %} + {% set modified_date = this.publication_date %} + {% if this.updated_date %} + {% set modified_date = this.updated_date %} + {% endif %} + {% set post_description = bag('blog.tagline') %} + {% if this.description %} + {% set post_description = this.description %} + {% endif %} + {% if this.category %} + {% set category = site.get("/categories/" + this.category).name %} + {% endif %} + + <script type="application/ld+json"> + { + "@context": "https://schema.org", + "@type": "BlogPosting", + "@id": "{{ post_id }}", + "mainEntityOfPage": "{{ post_url }}", + "url": "{{ post_url }}", + "isPartOf": { + "@id": "{{ blog_id }}" + }, + "headline": "{{ this.title }}", + "name": "{{ this.title }}", + "description": "{{ post_description }}", + "datePublished": "{{ this.publication_date | dateformat('yyyy-MM-dd') }}T00:00:00Z", + "dateModified": "{{ modified_date | dateformat('yyyy-MM-dd') }}T00:00:00Z", + "inLanguage": "en", + "author": { + "@id": "{{ person_id }}" + }, + "publisher": { + "@id": "{{ person_id }}" + }, + "keywords": "{{ this.tags | join(', ') }}", + "articleSection": "{{ category }}" + } + </script> + {% endif %} +{% endblock %} + {% block styles %} {{ super() }} <link rel="stylesheet" type="text/css" href="{{ '/static/css/blog.css'|asseturl }}"> {% endblock %} + {% block content %}{{ render_blog_post(this) }}{% endblock %} diff --git a/templates/blog.html b/templates/blog.html index 0ee96c7..4c011a1 100644 --- a/templates/blog.html +++ b/templates/blog.html @@ -6,10 +6,17 @@ {{ super() }} <meta property="og:type" content="website"> {% endblock %} + +{% block json_ld %} + {{ super() }} + {% include "includes/blog-json-ld.html" %} +{% endblock json_ld %} + {% block styles %} {{ super() }} <link rel="stylesheet" type="text/css" href="{{ '/static/css/blog.css'|asseturl }}"> {% endblock %} + {% block content %}{{ render_blog_index(this.pagination) }}{% endblock %} diff --git a/templates/includes/blog-json-ld.html b/templates/includes/blog-json-ld.html new file mode 100644 index 0000000..63d3c66 --- /dev/null +++ b/templates/includes/blog-json-ld.html @@ -0,0 +1,20 @@ +<script type="application/ld+json"> + { + "@context": "https://schema.org", + "@type": "Blog", + "@id": "{{ '/blog' | url(absolute=True, external=True) }}#blog", + "name": "{{ bag('blog.name') }}", + "description": "{{ bag('blog.tagline') }}", + "url": "{{ '/blog' | url(absolute=True, external=True) }}", + "inLanguage": "en", + "isPartOf": { + "@id": "{{ '/' | url(absolute=True, external=True) }}#website" + }, + "author": { + "@id": "{{ '/about' | url(absolute=True, external=True) }}#person" + }, + "publisher": { + "@id": "{{ '/about' | url(absolute=True, external=True) }}#person" + } + } +</script> diff --git a/templates/index.html b/templates/index.html index 0ee96c7..396114f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,15 +1 @@ -{% extends "base.html" %} - -{% from "macros/blog.html" import render_blog_index %} - -{% block meta %} - {{ super() }} - <meta property="og:type" content="website"> -{% endblock %} -{% block styles %} - {{ super() }} - <link rel="stylesheet" - type="text/css" - href="{{ '/static/css/blog.css'|asseturl }}"> -{% endblock %} -{% block content %}{{ render_blog_index(this.pagination) }}{% endblock %} +{% include "blog.html" %} diff --git a/templates/macros/blog.html b/templates/macros/blog.html index b4caafe..904e59e 100644 --- a/templates/macros/blog.html +++ b/templates/macros/blog.html @@ -19,11 +19,11 @@ {% endmacro %} {% macro render_blog_post(post, show_toc=True) %} - <article> + <article class="h-entry"> <header> <div> <h2> - <a href="{{ post|url }}">{{ post.title }}</a> + <a href="{{ post|url }}" class="u-url p-name">{{ post.title }}</a> </h2> <dl> {% if post.publication_date %} @@ -31,7 +31,8 @@ <dt>Posted:</dt> <dd> <a href="{{ ('/blog@index-pages/year/{}'.format(post.publication_date.year) ) | url }}"> - <time datetime="{{ post.publication_date | dateformat('yyyy-MM-dd') }}">{{ post.publication_date | dateformat("d MMMM yyyy") }}</time> + <time datetime="{{ post.publication_date | dateformat('yyyy-MM-dd') }}" + class="dt-published">{{ post.publication_date | dateformat("d MMMM yyyy") }}</time> </a> </dd> </div> @@ -47,7 +48,8 @@ <div> <dt>Last updated:</dt> <dd> - <time datetime="{{ post.updated_date | dateformat('yyyy-MM-dd') }}">{{ post.updated_date | dateformat("d MMMM yyyy") }}</time> + <time datetime="{{ post.updated_date | dateformat('yyyy-MM-dd') }}" + class="dt-updated">{{ post.updated_date | dateformat("d MMMM yyyy") }}</time> </dd> </div> {% endif %} @@ -56,10 +58,13 @@ <dt>Category:</dt> <dd> {% set category = site.get('/categories/'+post.category) %} - <a href="{{ category|url }}">{{ category.name }}</a> + <a href="{{ category|url }}" class="p-category">{{ category.name }}</a> </dd> </div> {% endif %} + <a rel="author" + class="p-author h-card display-none" + href="{{ '/about' | url(absolute=True) }}">Dennis Fink</a> </dl> </div> {% if show_toc and post.render_toc %} @@ -67,7 +72,7 @@ {{ render_toc(toc) }} {% endif %} </header> - {{ post.body }} + <div class="e-content">{{ post.body }}</div> {% if post.tags %} <footer> <p>Tagged with</p> @@ -75,7 +80,9 @@ {% for tag in post.tags %} <li> {% set tag_slug = tag|trim|lower|replace(" ", "-") %} - <a href="{{ ('/blog/tag/' ~ tag_slug ~ '/')|url }}" rel="tag">{{ tag }}</a> + <a href="{{ ('/blog/tag/' ~ tag_slug ~ '/')|url }}" + rel="tag" + class="p-category">{{ tag }}</a> {%- if not loop.last -%}, {%- else -%}.{%- endif -%} </li> {% endfor %} |
