Skip to content

Instantly share code, notes, and snippets.

@inetbiz
Last active September 24, 2021 16:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inetbiz/4824fa154075499bd323259ad4c4145d to your computer and use it in GitHub Desktop.
Save inetbiz/4824fa154075499bd323259ad4c4145d to your computer and use it in GitHub Desktop.
Jekyll Schema BreadCrumbs in JSON Format
"breadcrumb": {
"@type": "BreadcrumbList",
"itemListElement": [
{% assign crumbs = page.url | remove:'/index.html' | split: '/' %} {% assign crumbs_total = crumbs | size | minus: 1 %}{% for crumb in crumbs offset: 1 %}{% if forloop.index == crumbs_total %}
{
"@type": "ListItem",
"position": "{{ forloop.index }}",
"item": {
"@id": "{{ site.url }}{{ page.url }}",
"name": "{{ page.crumbtitle}}"
}
}{% else %}
{
"@type": "ListItem",
"position": "{{ forloop.index }}",
"item": {
"@id": "{% assign crumb_limit = forloop.index %}{% for crumb in crumbs limit: crumb_limit %}{{ crumb | append: '/' }}{% endfor %}",
"name": "{{ crumb | replace:'-',' ' | capitalize }}"
}
},{% endif %}{% endfor %}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment