diff --git a/lemoncurry/templates/lemoncurry/layout.html b/lemoncurry/templates/lemoncurry/layout.html
index 3fa1a38..3134ffa 100644
--- a/lemoncurry/templates/lemoncurry/layout.html
+++ b/lemoncurry/templates/lemoncurry/layout.html
@@ -1,7 +1,7 @@
{% load compress favtags lemoncurry_tags meta static %}
-
{% site_name as site_name %}{% request_uri request as uri %}
-
+ {% site_name as site_name %}{% request_uri request as uri %}{% request_origin request as origin %}
+
{% if title %}{{ title }} ~ {% endif %}{{ site_name }}
@@ -37,7 +37,7 @@
{% if request.resolver_match.view_name %}
- {% nav_crumbs request.resolver_match.view_name title %}
+ {% nav_crumbs request.resolver_match.view_name %}
{% endif %}
diff --git a/lemoncurry/templates/lemoncurry/tags/breadcrumbs.html b/lemoncurry/templates/lemoncurry/tags/breadcrumbs.html
index 1fa0aea..333f83e 100644
--- a/lemoncurry/templates/lemoncurry/tags/breadcrumbs.html
+++ b/lemoncurry/templates/lemoncurry/tags/breadcrumbs.html
@@ -1,4 +1,4 @@
-{% if crumbs %}
+{% load jsonify %}{% if crumbs %}
{% endif %}
diff --git a/lemoncurry/templatetags/jsonify.py b/lemoncurry/templatetags/jsonify.py
new file mode 100644
index 0000000..377ebb7
--- /dev/null
+++ b/lemoncurry/templatetags/jsonify.py
@@ -0,0 +1,15 @@
+from django import template
+from django.core.serializers import serialize
+from django.core.serializers.json import DjangoJSONEncoder
+from django.db.models.query import QuerySet
+from django.utils.safestring import mark_safe
+import json
+
+register = template.Library()
+
+
+@register.filter
+def jsonify(value):
+ if isinstance(value, QuerySet):
+ return mark_safe(serialize('json', value))
+ return mark_safe(json.dumps(value, cls=DjangoJSONEncoder))
diff --git a/lemoncurry/templatetags/lemoncurry_tags.py b/lemoncurry/templatetags/lemoncurry_tags.py
index c9c2017..49277d7 100644
--- a/lemoncurry/templatetags/lemoncurry_tags.py
+++ b/lemoncurry/templatetags/lemoncurry_tags.py
@@ -71,8 +71,39 @@ def nav_right(request):
return {'items': items, 'request': request}
-@register.inclusion_tag('lemoncurry/tags/breadcrumbs.html')
-def nav_crumbs(route, title):
+@register.inclusion_tag('lemoncurry/tags/breadcrumbs.html', takes_context=True)
+def nav_crumbs(context, route):
crumbs = breadcrumbs.find(route)
current = crumbs.pop()
- return {'crumbs': crumbs, 'current': current, 'title': title}
+
+ item_list_element = [{
+ '@type': 'ListItem',
+ 'position': i + 1,
+ 'item': {
+ '@id': context['origin'] + reverse(crumb['route']),
+ '@type': 'WebPage',
+ 'name': crumb['label']
+ }
+ } for i, crumb in enumerate(crumbs)]
+ item_list_element.append({
+ '@type': 'ListItem',
+ 'position': len(item_list_element) + 1,
+ 'item': {
+ 'id': context['uri'],
+ '@type': 'WebPage',
+ 'name': current['label'] or context.get('title'),
+ }
+ })
+
+ breadcrumb_list = {
+ '@context': 'http://schema.org',
+ '@type': 'BreadcrumbList',
+ 'itemListElement': item_list_element
+ }
+
+ return {
+ 'breadcrumb_list': breadcrumb_list,
+ 'crumbs': crumbs,
+ 'current': current,
+ 'title': context['title'],
+ }