Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
please provide a valid dynamic breadcrumb schema JSON-LD script
Solved! Go to the solution
This is an accepted solution.
@LookandAdorn Please find the code below:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "{{ shop.url }}"
},
{%- if template == 'collection' -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ collection.title }}",
"item": "{{ collection.url }}"
}
{%- elsif template == 'product' -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ collection.title }}",
"item": "{{ collection.url }}"
},
{
"@type": "ListItem",
"position": 3,
"name": "{{ product.title }}",
"item": "{{ product.url }}"
}
{%- else -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ page.title }}",
"item": "{{ shop.url }}{{ request.path }}"
}
{%- endif -%}
]
}
</script>
This is an accepted solution.
@LookandAdorn Please use updated one
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "{{ shop.url }}"
},
{%- if template == 'collection' -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ collection.title }}",
"item": "{{ collection.url }}"
}
{%- elsif template == 'product' -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ product.title }}",
"item": "{{ product.url }}"
}
{%- else -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ page.title }}",
"item": "{{ shop.url }}{{ request.path }}"
}
{%- endif -%}
]
}
</script>
This is an accepted solution.
@LookandAdorn Please find the code below:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "{{ shop.url }}"
},
{%- if template == 'collection' -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ collection.title }}",
"item": "{{ collection.url }}"
}
{%- elsif template == 'product' -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ collection.title }}",
"item": "{{ collection.url }}"
},
{
"@type": "ListItem",
"position": 3,
"name": "{{ product.title }}",
"item": "{{ product.url }}"
}
{%- else -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ page.title }}",
"item": "{{ shop.url }}{{ request.path }}"
}
{%- endif -%}
]
}
</script>
Getting the below mentioned error -
https://search.google.com/test/rich-results/result/r%2Fbreadcrumbs?id=iXdYNY8SDyGgPHYlIrJEBw
This is an accepted solution.
@LookandAdorn Please use updated one
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "{{ shop.url }}"
},
{%- if template == 'collection' -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ collection.title }}",
"item": "{{ collection.url }}"
}
{%- elsif template == 'product' -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ product.title }}",
"item": "{{ product.url }}"
}
{%- else -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ page.title }}",
"item": "{{ shop.url }}{{ request.path }}"
}
{%- endif -%}
]
}
</script>
@webwondersco wrote:@LookandAdorn Please use updated one
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "{{ shop.url }}"
},
{%- if template == 'collection' -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ collection.title }}",
"item": "{{ collection.url }}"
}
{%- elsif template == 'product' -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ product.title }}",
"item": "{{ product.url }}"
}
{%- else -%}
{
"@type": "ListItem",
"position": 2,
"name": "{{ page.title }}",
"item": "{{ shop.url }}{{ request.path }}"
}
{%- endif -%}
]
}
</script>
Thank you 👍 so much. I appreciate your quick response
Trying to implement this myself, but is getting "Unnamed item"-error in Rich Results Test for product pages. It seems that the product-title isn't rendered.
I have created a snippet with your updated code and I am rendering it in theme.liquid.
Please help!
Hi, I think I have figured it out. This is the code I tried now:
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Hem",
"item": "{{ shop.url }}"
}
{% if template contains 'collection' %}
,{
"@type": "ListItem",
"position": 2,
"name": "{{ collection.title | escape }}",
"item": "{{ collection.url | prepend: shop.url }}"
}
{% elsif template contains 'product' %}
{% if collection %}
,{
"@type": "ListItem",
"position": 2,
"name": "{{ collection.title | escape }}",
"item": "{{ collection.url | prepend: shop.url }}"
}
{% endif %}
,{
"@type": "ListItem",
"position": 3,
"name": "{{ product.title | escape }}",
"item": "{{ product.url | prepend: shop.url }}"
}
{% elsif template contains 'page' %}
,{
"@type": "ListItem",
"position": 2,
"name": "{{ page.title | escape }}",
"item": "{{ page.url | prepend: shop.url }}"
}
{% endif %}
]
}
</script>
Hi,
Can you please specify where we need to update this above code?