From e04012f4dae9bf0ad524c5869cf82f92d307cbae Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Wed, 4 Nov 2026 18:45:14 +0100 Subject: Ensure proper JSON encoding in structured data This applies Jinja's `tojson` filter to dynamically generated text fields in the site's JSON-LD templates, including titles, descriptions, keywords, and categories. This ensures special characters are escaped correctly and prevents invalid JSON in the generated structured data. --- templates/blog-post.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'templates/blog-post.html') diff --git a/templates/blog-post.html b/templates/blog-post.html index 4f1e5a2..10f8f7e 100644 --- a/templates/blog-post.html +++ b/templates/blog-post.html @@ -74,9 +74,9 @@ "isPartOf": { "@id": "{{ blog_id }}" }, - "headline": "{{ this.title }}", - "name": "{{ this.title }}", - "description": "{{ post_description }}", + "headline": {{ this.title | tojson }}, + "name": {{ this.title | tojson }}, + "description": {{ post_description | tojson }}, "datePublished": "{{ this.publication_date | dateformat('yyyy-MM-dd') }}T00:00:00Z", "dateModified": "{{ modified_date | dateformat('yyyy-MM-dd') }}T00:00:00Z", "inLanguage": "en", @@ -86,8 +86,8 @@ "publisher": { "@id": "{{ person_id }}" }, - "keywords": "{{ this.tags | join(', ') }}", - "articleSection": "{{ category }}" + "keywords": {{ this.tags | join(', ') | tojson }}, + "articleSection": {{ category | tojson }} } {% endif %} -- cgit v1.3.1