Application ld json data in shopify
To implement application/ld json in your shopify theme, add following code into your theme.liquid file.
{% if template == 'product' %}
<script type="application/ld+json">
{"@context":"https://schema.org",
"@type":"Product",
"name":"{{ product.title }}",
"description":"{{ product.description | strip_html | escape }}",
"url":"{{ shop.url | append: '/products/' | append: product.handle }}",
"brand":
{"@type":"Brand",
"name":"{{ product.vendor }}",
"image":"{{ product.featured_image.src | img_url: 'master'}}",
"url":"{{collection_urls}}"},
{% if product.metafields.yotpo.reviews_count and product.metafields.yotpo.reviews_count != "0" %}
"aggregateRating":
{"@type":"AggregateRating",
"ratingValue":"{{product.metafields.yotpo.reviews_average}}",
"reviewCount":"{{product.metafields.yotpo.reviews_count}}"},
{% endif %}
"offers":[
{% for variant in product.variants %}
{% if forloop.last %}
{"@type":"Offer",
"image":"{{variant.image.src}}",
"sku":"{{variant.sku}}",
"price":"{{ product.price |money_without_currency}}",
"priceCurrency":"{{shop.currency}}",
"availability":"http://schema.org/{% if variant.available%}InStock{%else%}OutOfStock{%endif%}",
"itemCondition":"https://schema.org/NewCondition",
"seller":{"@type": "Organization","name": "{{ shop.name }}"}}
{% else %}
{"@type":"Offer",
"image":"{{variant.image.src}}",
"sku":"{{variant.sku}}",
"price":"{{ product.price |money_without_currency}}",
"priceCurrency":"{{shop.currency}}",
"availability":"http://schema.org/{% if variant.available%}InStock{%else%}OutOfStock{%endif%}",
"itemCondition":"https://schema.org/NewCondition",
"seller":{"@type": "Organization","name": "{{ shop.name }}"}},
{% endif %}
{% endfor %}]
}
</script>
{% endif %}
Comments
Post a Comment