diff options
| author | Dennis Fink | 2026-11-04 18:45:14 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-04 18:45:14 +0100 |
| commit | e04012f4dae9bf0ad524c5869cf82f92d307cbae (patch) | |
| tree | 18509bb37912921e9dcf31c48dca8212d0e19566 /templates/blog-post.html | |
| parent | e7e365c239f766a8d2271c233f16c4df53a9bbb3 (diff) | |
| download | dennisfink.me-e04012f4dae9bf0ad524c5869cf82f92d307cbae.tar.gz dennisfink.me-e04012f4dae9bf0ad524c5869cf82f92d307cbae.zip | |
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.
Diffstat (limited to 'templates/blog-post.html')
| -rw-r--r-- | templates/blog-post.html | 10 |
1 files changed, 5 insertions, 5 deletions
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 }} } </script> {% endif %} |
