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 /templates/blog-post.html | |
| 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-- | templates/blog-post.html | 53 |
1 files changed, 53 insertions, 0 deletions
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 %} |
