Skip to content

Commit 3f7e0ba

Browse files
committed
schema.org JSON-LD metadata in posts
1 parent 48235ca commit 3f7e0ba

File tree

10 files changed

+80
-40
lines changed

10 files changed

+80
-40
lines changed

src/11ty-notes/Sparna_new_website_using_eleventy.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -237,25 +237,25 @@ Iterate on collections and output the feed
237237
```html
238238
{% raw %}
239239
---
240-
# Metadata comes from _data/metadata.json
241-
permalink: "{{ metadata.feed.path }}"
240+
# Metadata comes from _data/site.json
241+
permalink: "{{ site.feed.path }}"
242242
eleventyExcludeFromCollections: true
243243
---
244244
<?xml version="1.0" encoding="utf-8"?>
245245
<feed xmlns="http://www.w3.org/2005/Atom">
246-
<title>{{ metadata.title }}</title>
247-
<subtitle>{{ metadata.feed.subtitle }}</subtitle>
248-
{% set absoluteUrl %}{{ metadata.feed.path | url | absoluteUrl(metadata.url) }}{% endset %}
246+
<title>{{ site.title }}</title>
247+
<subtitle>{{ site.feed.subtitle }}</subtitle>
248+
{% set absoluteUrl %}{{ site.feed.path | url | absoluteUrl(site.url) }}{% endset %}
249249
<link href="{{ absoluteUrl }}" rel="self"/>
250-
<link href="{{ metadata.url }}"/>
250+
<link href="{{ site.url }}"/>
251251
<updated>{{ collections.posts | rssLastUpdatedDate }}</updated>
252-
<id>{{ metadata.feed.id }}</id>
252+
<id>{{ site.feed.id }}</id>
253253
<author>
254-
<name>{{ metadata.author.name }}</name>
255-
<email>{{ metadata.author.email }}</email>
254+
<name>{{ site.author.name }}</name>
255+
<email>{{ site.author.email }}</email>
256256
</author>
257257
{%- for post in collections.posts | reverse %}
258-
{% set absolutePostUrl %}{{ post.url | url | absoluteUrl(metadata.url) }}{% endset %}
258+
{% set absolutePostUrl %}{{ post.url | url | absoluteUrl(site.url) }}{% endset %}
259259
<entry>
260260
<title>{{ post.data.title }}</title>
261261
<link href="{{ absolutePostUrl }}"/>
@@ -274,7 +274,7 @@ eleventyExcludeFromCollections: true
274274
eleventyComputed:
275275
meta:
276276
author:
277-
name: "{{ metadata.author.name }}"
277+
name: "{{ site.author.name }}"
278278
published: "{{ date | iso8601 }}"
279279
modified: "{% if updateDate %}{{ updateDate | iso8601 }}{% endif %}"
280280
```

src/_data/site.js

Whitespace-only changes.
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
{
2-
"title": "Sparna.fr",
2+
"title": "Sparna website",
33
"description": "Linked Data - Knowledge Graphs - Ontologies - AI | Sparna",
44
"url": "https://www.sparna.fr",
55
"author": {
66
"name": "Thomas Francart",
7+
"email": "thomas.francart@sparna.fr",
78
"url": "https://www.linkedin.com/in/thomasfrancart/"
89
},
10+
"feed": {
11+
"id":"sparna.fr-123456uuid",
12+
"title":"Sparna blog posts",
13+
"subtitle":"About Linked Data - Knowledge Graphs - Ontologies - AI",
14+
"path":"https://www.sparna.fr/rss.xml"
15+
},
916
"repo":"https://github.com/sparna-git/sparna.fr"
1017
}

src/_layouts/11ty-notes.njk

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
eleventyComputed:
33
meta:
44
site:
5-
name: "{{ metadata.title }}"
6-
description: "{{ metadata.description }}"
7-
url: "{{ metadata.url }}"
5+
name: "{{ site.title }}"
6+
description: "{{ site.description }}"
7+
url: "{{ site.url }}"
88
logo:
99
src: https://example.com/images/logo.png
1010
width: 1200
1111
height: 630
12-
title: "{{ title or metadata.title }}"
13-
description: "{{ description or metadata.description }}"
12+
title: "{{ title or site.title }}"
13+
description: "{{ description or site.description }}"
1414
image:
15-
src: "{% if image %}{{ metadata.url }}{{ image }}{% endif %}"
15+
src: "{% if image %}{{ site.url }}{{ image }}{% endif %}"
1616
---
1717

1818
<!DOCTYPE html>

src/_layouts/post-schemaorg.njk

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{% macro schemaorg(object) %}
2+
{% set image = page.rawInput | extractFirstImage %}
3+
<script type="application/ld+json">
4+
{
5+
"@context" : "http://schema.org",
6+
"@type" : "BlogPosting",
7+
"@id" : "{{ site.url }}{{ page.url | url }}",
8+
"headline" : "{{ title }}",
9+
"datePublished" : "{{ page.date | dateToISO }}",
10+
"publisher" : {
11+
"@type" : "Organization",
12+
"name" : "Sparna",
13+
"@id" : "https://sparna.fr",
14+
"url" : "https://www.sparna.fr"
15+
},
16+
"inLanguage" : "{{ page.lang }}"{% if author %},
17+
"author": {
18+
"@type" : "Person",
19+
"name" : "{{ author }}",
20+
"url" : "{{ site.url }}/{{ lang }}/auteurs/{{ author | slugify }}"
21+
}{% endif %}{% if image %},
22+
"image": "{{ site.url }}{{ image }}"{% endif %}{% if tags %},
23+
"keywords": "{{ tags | join(', ') }}",
24+
"about": [
25+
{%- for tag in tags -%}
26+
{% if loop.index0 > 0 %},{% endif%}"{{ tag | trim }}"
27+
{% endfor %}
28+
]{% endif %}{% if linkedin or mastodon or bluesky %},
29+
"discussionUrl": [
30+
{% if linkedin %}"{{ linkedin }}"{% if mastodon or bluesky %},{% endif %}{% endif %}
31+
{% if mastodon %}"{{ mastodon }}"{% if bluesky %},{% endif %}{% endif %}
32+
{% if bluesky %}"{{ bluesky }}"{% endif %}
33+
]
34+
{% endif %}
35+
}
36+
</script>
37+
{% endmacro %}

src/_layouts/post.njk

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,29 @@ layout: sparna.njk
33
bodyClass: single single-post
44
---
55

6+
{# "with context" means the imported templates will have access to all data #}
7+
{# see https://mozilla.github.io/nunjucks/templating.html#import #}
8+
{% import "src/_layouts/post-schemaorg.njk" as schemaorg with context %}
9+
10+
{{ schemaorg.schemaorg(page.data) }}
11+
612
<article
713
id="{{ title | slug }}"
814
class="post h-entry"
915
role="article"
1016
itemscope
1117
itemtype="http://schema.org/BlogPosting"
18+
itemid="{{ site.url }}{{ page.url | url }}"
1219
aria-labelledby="{{ title | slug }}-title"
1320
>
1421

15-
16-
{% set image = page.rawInput | extractFirstImage %}
17-
{% if image %}
18-
<meta itemprop="image" content="{{ metadata.url }}{{ image }}" />
19-
{% endif %}
20-
2122
<div class="post__header">
22-
<h1 id="{{ title | slug }}-title" class="post__title p-name title" itemprop="headline">{{ title }}</h1>
23+
<h1 id="{{ title | slug }}-title" class="post__title p-name title">{{ title }}</h1>
2324
<div class="post__meta">
2425
<p>
25-
<time class="post__date dt-published" itemprop="datePublished" datetime="{{ page.date | dateToISO }}">{{ page.date | readableDate('dd MMM yyyy', locale) }}</time>
26+
<time class="post__date dt-published">{{ page.date | readableDate('dd MMM yyyy', locale) }}</time>
2627
{% if author %}
27-
<span aria-label="author">&middot;</span> <span class="post__author p-author">by
28-
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
29-
<a href="/{{ lang }}/auteurs/{{ author | slugify }}" itemprop="url">
30-
<span itemprop="name">{{ author }}</span>
31-
</a>
32-
</span>
28+
<span aria-label="author">&middot;</span> <span class="post__author p-author">by <span>{{ author }}</span>
3329
</span>
3430
{% endif %}
3531
{% if tags %}
@@ -52,7 +48,7 @@ bodyClass: single single-post
5248

5349
<p class="post__footer-info">
5450
{% if tags %}Published in {{ tags | join(', ') }} &middot; {% endif %}{{ page.date | readableDate('dd LLL yyyy', locale) }} <br/>
55-
<a href="{{ metadata.repo }}/tree/master/{{ page.inputPath }}" title="suggest a change to this post by submitting a PR">edit this post</a>
51+
<a href="{{ site.repo }}/tree/master/{{ page.inputPath }}" title="suggest a change to this post by submitting a PR">edit this post</a>
5652
</p>
5753

5854

src/_layouts/sparna.njk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<meta name="viewport" content="width=device-width">
66
<title>{{ title }}</title>
77
<meta name="google-site-verification" content="IkU6vMBuAjxGZlU-z2UeeeDTxfSy_M5bSfF9vcPCAsI" />
8-
<link rel="canonical" href="{{ metadata.url }}{{ page.url }}" />
8+
<link rel="canonical" href="{{ site.url }}{{ page.url }}" />
99

10-
<link rel="alternate" hreflang="{{ page.lang }}" href="{{ metadata.url }}{{ page.url }}"/>
10+
<link rel="alternate" hreflang="{{ page.lang }}" href="{{ site.url }}{{ page.url }}"/>
1111
{% for link in page.url | locale_links %}
12-
<link rel="alternate" hreflang="{{ link.lang }}" href="{{ metadata.url }}{{link.url}}">
12+
<link rel="alternate" hreflang="{{ link.lang }}" href="{{ site.url }}{{link.url}}">
1313
{% endfor %}
1414

1515
<link rel="icon" href="{{ '/assets/icons/favicon.ico' | relative(page) }}">
@@ -31,7 +31,7 @@
3131
<meta property="og:type" content="article" />
3232
<meta property="og:title" content="Sparna" />
3333
<meta property="og:description" content="Web de données | Architecture de l&#039;informations | Accès aux connaissances" />
34-
<meta property="og:url" content="{{ metadata.url }}{{ page.url }}" />
34+
<meta property="og:url" content="{{ site.url }}{{ page.url }}" />
3535
<meta property="og:site_name" content="Sparna" />
3636
<meta property="og:image" content="{{ '/assets/images/logo.png' | relative(page) }}" />
3737
<meta property="og:locale" content="{{ page.lang }}" />

src/en/posts/20250414-SAPA.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: "Fondation SAPA : un graphe de données liées au coeur des archives"
44
author: Thomas Francart
55
date: 2025-04-14
66
description: "Un graphe de connaissance à 3 niveaux : archives, fichiers media, entités nommées (connaissance)"
7-
tags: RiC-O, FRBRoo, CIDOC-CRM
7+
tags: SAPA, RiC-O, FRBRoo, CIDOC-CRM, SKOS, Archives, Sparnatural
88
permalink: en/posts/{{ title | slugify }}/
99
linkedin: https://www.linkedin.com/posts/thomasfrancart_graphes-de-connaissances-et-archives-%C3%A9pisode-activity-7318237605584637971-MqBc
1010
bluesky: https://bsky.app/profile/chutjeveille.bsky.social/post/3lmwyy6bm7c26

src/en/posts/20250414-labels-in-Sparnatural.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: post.njk
33
title: "Multilingualism, multi-labels : how to play and display the literals of a graph in Sparnatural"
4-
author: Marie Muller, Thomas Francart
4+
author: Marie Muller
55
date: 2025-05-07
66
description: "Making your data accessible to users that don’t necessarily speak the same language as the one used in your dataset"
77
tags: multilingualism, Sparnatural, labels

src/sitemap.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ eleventyExcludeFromCollections: true
77
{% for page in collections.all %}
88
{% if page.data.excludeFromSitemap != true %}
99
<url>
10-
<loc>{{ metadata.url }}{{ page.url | url }}</loc>
10+
<loc>{{ site.url }}{{ page.url | url }}</loc>
1111
{% if page.data.date %}
1212
<lastmod>{{ page.data.date.toISOString() }}</lastmod>
1313
{% else %}

0 commit comments

Comments
 (0)