Liquid, JavaScript, themes, sales channels
Hi There,
I'm currently migrating my store from the old Debut theme to the new Dawn theme, but I'm unable to find the structured data part for the products. Is there maybe a reason this is no longer needed, or has it moved outside of the theme code?
Your help would be much appreciated, thank you.
Solved! Go to the solution
This is an accepted solution.
Hi @Gunnar-
structured data is not deprecated and still very important for Google and other search engines, Facebook, etc.
Dawn has been built from scratch and at the moment they are focused on the essential features. Could be that they will decide to add that part in future.
Hi @Gunnar-
You can see the instructions at this link: https://shopify.dev/themes/migration
Hi @Henry_dev ,
Thank you for your quick reply, however, this guide does not mention the structured data of the old product template from Debut and it's nowhere to be found in the new Dawn theme, so it's not really an answer to my question. I'm talking about this part:
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": {{ product.title | json }},
"url": {{ shop.url | append: product.url | json }},
{%- if product.featured_media -%}
{%- assign media_size = product.featured_media.preview_image.width | append: 'x' -%}
"image": [
{{ product.featured_media | img_url: media_size | prepend: "https:" | json }}
],
{%- endif -%}
"description": {{ product.description | strip_html | json }},
{%- if current_variant.sku != blank -%}
"sku": {{ current_variant.sku | json }},
{%- endif -%}
"brand": {
"@type": "Thing",
"name": {{ product.vendor | json }}
},
"offers": [
{%- for variant in product.variants -%}
{
"@type" : "Offer",
{%- if variant.sku != blank -%}
"sku": {{ variant.sku | json }},
{%- endif -%}
"availability" : "http://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
"price" : {{ variant.price | divided_by: 100.00 | json }},
"priceCurrency" : {{ cart.currency.iso_code | json }},
"url" : {{ shop.url | append: variant.url | json }}
}{% unless forloop.last %},{% endunless %}
{%- endfor -%}
]
}
</script>
Thank you in advance.
In which file did you write this code?
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": {{ product.title | json }},
"url": {{ shop.url | append: product.url | json }},
{%- if product.featured_media -%}
{%- assign media_size = product.featured_media.preview_image.width | append: 'x' -%}
"image": [
{{ product.featured_media | img_url: media_size | prepend: "https:" | json }}
],
{%- endif -%}
"description": {{ product.description | strip_html | json }},
{%- if current_variant.sku != blank -%}
"sku": {{ current_variant.sku | json }},
{%- endif -%}
"brand": {
"@type": "Thing",
"name": {{ product.vendor | json }}
},
"offers": [
{%- for variant in product.variants -%}
{
"@type" : "Offer",
{%- if variant.sku != blank -%}
"sku": {{ variant.sku | json }},
{%- endif -%}
"availability" : "http://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
"price" : {{ variant.price | divided_by: 100.00 | json }},
"priceCurrency" : {{ cart.currency.iso_code | json }},
"url" : {{ shop.url | append: variant.url | json }}
}{% unless forloop.last %},{% endunless %}
{%- endfor -%}
]
}
</script>
Have you converted the file in templates/product.liquid =>> templates/product.json?
Hi @Henry_dev ,
That code comes from the product.liquid template file from the Debut theme and is nowhere to be found in the Dawn theme (I would expect to find it in the main-product.liquid section).
Thank you.
In the Dawn theme that code is deprecated. However you can create a new section like main-product.liquid and copy all the code in the product.liquid file to the main-product.liquid file
Example: sections/main-product.liquid:
<script>
// Override default values of shop.strings for each template.
// Alternate product templates can change values of
// add to cart button, sold out, and unavailable states here.
theme.productStrings = {
addToCart: {{ 'products.product.add_to_cart' | t | json }},
soldOut: {{ 'products.product.sold_out' | t | json }},
unavailable: {{ 'products.product.unavailable' | t | json }}
};
if(sessionStorage.backToCollection) {
theme.backToCollection = {};
theme.backToCollection.collection = JSON.parse(sessionStorage.backToCollection);
var productCollections = {{ product.collections | json }};
var showCollection = false;
if (productCollections) {
productCollections.forEach(function(collection) {
if (collection.title === theme.backToCollection.collection.title) {
showCollection = true;
}
});
}
if(showCollection) {
var backToCollectionHTML = '<div class="text-center return-link-wrapper page-width"><a href="' + theme.backToCollection.collection.link + '" class="btn btn--secondary btn--has-icon-before">{% include 'icon-arrow-left' %}{{ 'products.product.back_to_collection' | t }} ' + theme.backToCollection.collection.title + '</a></div>';
var backToCollectionContainer = document.getElementById('backToCollection');
backToCollectionContainer.insertAdjacentHTML('afterbegin', backToCollectionHTML);
}
}
</script>
{% assign current_variant = product.selected_or_first_available_variant %}
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": {{ product.title | json }},
"url": {{ shop.url | append: product.url | json }},
{%- if product.featured_media -%}
{%- assign media_size = product.featured_media.preview_image.width | append: 'x' -%}
"image": [
{{ product.featured_media | img_url: media_size | prepend: "https:" | json }}
],
{%- endif -%}
"description": {{ product.description | strip_html | json }},
{%- if current_variant.sku != blank -%}
"sku": {{ current_variant.sku | json }},
{%- endif -%}
"brand": {
"@type": "Thing",
"name": {{ product.vendor | json }}
},
"offers": [
{%- for variant in product.variants -%}
{
"@type" : "Offer",
{%- if variant.sku != blank -%}
"sku": {{ variant.sku | json }},
{%- endif -%}
"availability" : "http://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
"price" : {{ variant.price | divided_by: 100.00 | json }},
"priceCurrency" : {{ cart.currency.iso_code | json }},
"url" : {{ shop.url | append: variant.url | json }}
}{% unless forloop.last %},{% endunless %}
{%- endfor -%}
]
}
</script>
Going back to product.liquid you modify it to look like this:
{
"name": "Product",
"sections": {
"main": {
"type": "main-product"
}
},
"order": [
"main"
]
}
Hi @Henry_dev ,
So, it's the depreciated part I'm actually interested in, why is this not needed anymore? How is Google getting their rich results now?
Thanks for the fast help by the way.
This is an accepted solution.
Hi @Gunnar-
structured data is not deprecated and still very important for Google and other search engines, Facebook, etc.
Dawn has been built from scratch and at the moment they are focused on the essential features. Could be that they will decide to add that part in future.
Dawn does not have structured data for products at this time. I was only able to find limited data for articles which means you're also missing structured data for your organization, pages, products etc.
Anyone using Dawn at this point will need to either code the structured data themselves or use an app such as JSON-LD for SEO. The risk of doing it yourself is that it needs to be maintained and updates to your theme can override your code changes.
Just wanted to follow up on this. The Dawn theme that is currently in the Shopify Theme store now has basic Product structured data.
is there a way to add SKU info to the products in Dawn 2.0?
Where is that basic Product structured data? Can I make changes to the Brand type of a product?
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