aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2024-01-18 09:47:03 +0100
committerGuido Günther <agx@sigxcpu.org>2024-01-18 15:55:32 +0100
commitfe17cc6568dceb980217529c87607dfe27817476 (patch)
tree5295a92540bf942398e489298116efc6c1759455
parent2fdd29656ce7bc7ab2c0ded6b60d339e8ec436f0 (diff)
Add JSON-ld for blog posts
See https://developers.google.com/search/docs/appearance/structured-data/article
-rw-r--r--jason-md7
-rw-r--r--layouts/partials/head/extensions.html6
-rw-r--r--layouts/shortcodes/jason-ld-blog.html29
-rw-r--r--posts.org5
4 files changed, 40 insertions, 7 deletions
diff --git a/jason-md b/jason-md
deleted file mode 100644
index 854c863..0000000
--- a/jason-md
+++ /dev/null
@@ -1,7 +0,0 @@
-We want rich results in google:
-
-https://developers.google.com/search/docs/appearance/structured-data/article#json-ld
-
-so our blogs are more prominent, see
-
-See https://bullaki.com/projects/web-design/seo-with-hugo-4-structured-data-markup/
diff --git a/layouts/partials/head/extensions.html b/layouts/partials/head/extensions.html
new file mode 100644
index 0000000..3f75ce9
--- /dev/null
+++ b/layouts/partials/head/extensions.html
@@ -0,0 +1,6 @@
+{{- $data := . -}}
+{{- with .Type -}}
+{{- if eq . "posts" -}}
+ {{- block "JSON-LD-blog" $data }}{{- end }}
+ {{- end -}}
+{{- end -}}
diff --git a/layouts/shortcodes/jason-ld-blog.html b/layouts/shortcodes/jason-ld-blog.html
new file mode 100644
index 0000000..ef039dd
--- /dev/null
+++ b/layouts/shortcodes/jason-ld-blog.html
@@ -0,0 +1,29 @@
+{{- define "JSON-LD-blog" -}}
+<script type="application/ld+json">
+ {
+ "@context": "https://schema.org/",
+ "@type": "Article",
+ "headline": "{{.Title}}",
+ "datePublished": "{{ .Date | time.Format "2006-01-02T15:04" }}",
+ {{- with .GetTerms "authors" }}
+ "author": [
+ {{- range $index, $el := . -}}
+ {{- if ne $index 0 -}},{{ end }}
+ {
+ "@type": "Person",
+ "name": {{- .LinkTitle }}
+ }
+ {{- end }}
+ ],
+ {{- end }}
+ {{- with .Resources.ByType "image" }}
+ "image":[
+ {{- range $index, $element := . -}}
+ {{- if ne $index 0 }},{{ end }}
+ {{ .Permalink -}}
+ {{ end }}
+ ]
+ {{- end }}
+ }
+ </script>
+{{- end -}}
diff --git a/posts.org b/posts.org
index b05dfb0..9b6b8a3 100644
--- a/posts.org
+++ b/posts.org
@@ -12,3 +12,8 @@
See https://headlinecapitalization.com/
- [ ] Is there an =images= set in the metadata
This generates the previews that are used e.g. in mastodon
+
+* Useful links
+
+ * Validate schema data (json-ld):
+ https://validator.schema.org/