Skip to content

Commit 05a019e

Browse files
add blogposting schema
1 parent 7bf1ab7 commit 05a019e

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

tbx/project_styleguide/templates/patterns/navigation/components/breadcrumbs-jsonld.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{% load wagtailcore_tags %}
2-
{% wagtail_site as current_site %}
32
{% if page.breadcrumbs %}
43
<script type="application/ld+json">
54
{
@@ -10,7 +9,7 @@
109
"@type": "ListItem",
1110
"position": {{ forloop.counter }},
1211
"name": "{% if crumb.depth == 2 %}Home{% else %}{{ crumb.title|escapejs }}{% endif %}",
13-
"item": "{{ current_site.root_url }}{% pageurl crumb %}"
12+
"item": "{% fullpageurl crumb %}"
1413
}{% if not forloop.last %},{% endif %}{% endfor %}
1514
]
1615
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% load wagtailcore_tags wagtailimages_tags %}
2+
<script type="application/ld+json">
3+
{
4+
"@context": "https://schema.org",
5+
"@type": "BlogPosting",
6+
"mainEntityOfPage": {
7+
"@type": "WebPage",
8+
"@id": "{% fullpageurl page %}"
9+
},
10+
"headline": "{{ page.title|escapejs }}",
11+
"description": "{% if page.search_description %}{{ page.search_description|escapejs }}{% elif page.listing_summary %}{{ page.listing_summary|escapejs }}{% endif %}"{% if page.feed_image %},
12+
"image": "{% image page.feed_image format-webp width-1200 as blog_image %}{{ blog_image.url }}"{% endif %}{% if page.first_author %},
13+
"author": {
14+
"@type": "Person",
15+
"name": "{{ page.first_author.name|escapejs }}"{% if page.first_author.person_page %},
16+
"url": "{% fullpageurl page.first_author.person_page %}"{% endif %}
17+
}{% endif %},
18+
"publisher": {
19+
"@type": "Organization",
20+
"name": "Torchbox",
21+
"logo": {
22+
"@type": "ImageObject",
23+
"url": "{% wagtail_site as current_site %}{{ current_site.root_url }}/apple-touch-icon.png"
24+
}
25+
},
26+
"datePublished": "{{ page.date|date:'Y-m-d' }}",
27+
"dateModified": "{% if page.last_published_at %}{{ page.last_published_at|date:'Y-m-d' }}{% else %}{{ page.date|date:'Y-m-d' }}{% endif %}"
28+
}
29+
</script>

tbx/project_styleguide/templates/patterns/pages/blog/blog_detail.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
{{ block.super }}
2323
{% endblock %}
2424

25+
{% block extra_jsonld %}
26+
{% include "patterns/pages/blog/blog-posting-jsonld.html" %}
27+
{% endblock %}
28+
2529
{% block content %}
2630
<div class="grid grid--spacer-large streamfield lg:relative">
2731
<div class="authors">

0 commit comments

Comments
 (0)