Shopify themes, liquid, logos, and UX
How can I improve the Schema.org markup for my Shopify products to include additional review properties, product-specific variables, and aggregate review data?
{% if product.reviews.size > 0 %}
{% assign ratingCount = product.reviews.size %}
{% assign ratingValue = 0 %}
{% for review in product.reviews %}
{% assign ratingValue = ratingValue | plus: review.rating %}
{% endfor %}
{% assign averageRating = ratingValue | divided_by: ratingCount %}
{% assign bestRating = 5 %}
{% assign worstRating = 1 %}
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "{{ product.title }}",
"image": "{{ product.featured_image.src | img_url: 'large' }}",
"description": "{{ product.description | strip_html | escape }}",
"sku": "{{ product.sku }}",
"mpn": "{{ product.metafields.global.manufacturer_part_number }}",
"brand": {
"@type": "Brand",
"name": "{{ product.vendor }}"
},
"offers": {
"@type": "Offer",
"price": "{{ product.price | money_without_currency }}",
"priceCurrency": "{{ shop.currency }}",
"availability": "{% if product.available %}https://schema.org/InStock{% else %}https://schema.org/OutOfStock{% endif %}",
"seller": {
"@type": "Organization",
"name": "{{ shop.name }}"
}
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "{{ averageRating }}",
"reviewCount": "{{ ratingCount }}",
"bestRating": "{{ bestRating }}",
"worstRating": "{{ worstRating }}"
},
"review": [
{% for review in product.reviews %}
{
"@type": "Review",
"author": {
"@type": "Person",
"name": "{{ review.author }}"
},
"datePublished": "{{ review.created_at | date: "%Y-%m-%d" }}",
"description": "{{ review.body | strip_html | escape }}",
"reviewRating": {
"@type": "Rating",
"ratingValue": "{{ review.rating }}",
"bestRating": "{{ bestRating }}",
"worstRating": "{{ worstRating }}"
}
{% if forloop.last == false %},{% endif %}
}
{% endfor %}
]
}
</script>
{% endif %}
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024