之前写的2篇结构化数据,这两年持续都有在更新,原来大部分内容还能用,但是有些数据需要调整更新。
这次主要更新的是,article & product 中的模板数据,应对以下错误内容。
检查这类问题,用到一个实时更新工具:https://validator.schema.org/
只要在 shopify 中更改了,然后使用这个工具,就可以实时检测更改的效果,有没有修改成功等,可以准确的指出哪个位置少了标点符号或中英文符号不对......
在产品模板中,judge.me 将原来读取产品 review 的数据元字段更新了,导致原来的数据读不到,所以,如果有用原来元字段的,这次要更新了。
assign review_value = product.metafields.judgeme.badge | split: "data-average-rating='" | last | split: "'" | first | plus: 0assign review_count = product.metafields.judgeme.badge | split: "data-number-of-reviews='" | last | split: "'" | first | plus: 0
<script type="application/ld+json"> { "@context": "http://schema.org/", "@type": "Product", "name": {{ product.title | json }}, "url": {{ shop.url | append: product.url | json }}, "image": [ {{ product.featured_media | img_url: media_size | prepend: "https:" | json }} ], "description": {{ product.description | strip_html | json }}, {% if product.selected_or_first_available_variant.sku != blank -%} "sku": {{ product.selected_or_first_available_variant.sku | json }}, {%- endif %} "review": { "@type": "Review", "reviewRating": { "@type": "Rating", "ratingValue": "{{ review_value }}", "bestRating": "5" }, "author": { "@type": "Person", "name": "kevin" } }, "aggregateRating": { "@type": "AggregateRating", "ratingValue": {{ review_value }}, "reviewCount": {{ review_count }} }, "brand": { "@type": "Brand", "name": {{ product.vendor | json }} }, "offers": [ {%- for variant in product.variants -%} { "@type" : "Offer", {%- if variant.sku != blank -%} "sku": {{ variant.sku | json }}, {%- endif -%} {%- if variant.barcode.size == 12 -%} "gtin12": {{ variant.barcode }}, {%- endif -%} {%- if variant.barcode.size == 13 -%} "gtin13": {{ variant.barcode }}, {%- endif -%} {%- if variant.barcode.size == 14 -%} "gtin14": {{ variant.barcode }}, {%- 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 }}, "priceValidUntil": {{ 'now' | date: '%s' | plus: 31536000 | date: '%Y-%m-%d' | replace:'+','%20' | json }}, "url" : {{ request.origin | append: variant.url | json }} } {% unless forloop.last %},{% endunless %} {%- endfor -%} ] }</script>
<script type="application/ld+json">{ "@context": "https://schema.org", "@type": "Article", "headline": {{ article.title | json }}, "image": {{ article.image | image_url | prepend: "https:" | json }}, "description":{{ article.excerpt | json }}, "datePublished": {{ article.created_at | date: '%Y-%m-%d' | replace:'+','%20' | json }}, "dateModified": {{ article.published_at | date: '%Y-%m-%d' | replace:'+','%20' | json }}, "author": { "@type": "Person", "name": "kevin" }, "publisher": { "@type": "Organization", "name": "Data Liberate", "logo": { "@type": "ImageObject", "url": "https://cdn.shopify.com/s/files/1/0716/1731/5114/files/LOGO.png?v=1747982376" } }, "wordCount": {{ article.comments_count }}, "keywords": [ "xxx", "xxxx", "......" ]}</script>