为 Shopify 产品页补充结构化数据

Shopify 的商品在 Google Search Console 里有警告,说是有几个字段(sku、priceValidUntil、brand等)缺失


了解需要补充的字段

虽然 Shopify 的员工在社区里回应说,这些警告没有太大影响,我们还是想把能加的字段给补充上

Brooklyn 主题把 Shopify 产品页的结构化数据字义为了一个 Product

所以,就先到 schema.org 找到了 Product 结构

了解了一下警告了所说的几个字段:skubrandpriceValidUntil

还有一些字段,产品并不包含,所以就不管它了(barcodereviewsrating之类)


添加字段

接下来把能加的字段给它加到页面里

brand 这个字段是确定的,写死就行。但 skupriceVAlideUntil 怎么取呢

查到了一个相关的文章Adding Structured Data to Shopify for Google Merchant & Facebook (JSON-LD),里面就讲到了 shopify 产品页里各种结构化数字怎么获取

1
2
3
4
5
{%- if product.variants.first.sku != blank -%}
"sku": "{{ product.variants.first.sku }}",
{%- else -%}

"priceValidUntil": "{{ 'now' | date: '%s' | plus: 31536000 | date: '%Y-%m-%d' | uri_encode | replace:'+','%20' }}"

明确了各个字段的值之后,就打开 product-template.liquid 页面,把它们添加上来

Brooklyn 主题里的结构化数据并没有使用 JSON-LD ,是直接写在页面结构里的,所以

1
2
3
4
5
6
7
<meta itemprop="brand" content="Pacer Adventure Challenge">

{% if current_variant.sku != blank %}
<meta itemprop="sku" content="{{ current_variant.sku }}">
{% endif %}

<meta itemprop="priceValidUntil" content="{{ 'now' | date: '%s' | plus: 31536000 | date: '%Y-%m-%d' | uri_encode | replace:'+','%20' }}">

校验

添加好之后,点击 Save

结构化数据测试工具里把对应的产品页面输上,运行测试

原文作者: dgb8901,yinxing

原文链接: https://www.itwork.club/2020/08/25/update-structured-data-for-shopify-product/

版权声明: 转载请注明出处

为您推荐

体验小程序「简易记账」

关注公众号「特想学英语」

使用 Puppeteer 在 Node 环境生成 HTML 截图