如何在Shopify上实现Schema.org标记?

如何在Shopify上实现Schema.org标记?,shopify,schema.org,json-ld,Shopify,Schema.org,Json Ld,我最近开始为一家美容公司工作,他想为他们的产品页面实现丰富的代码片段。我知道Schema.org标记是如何工作的,因为我复制了一个通用的组织,一个我的朋友为一家移动应用开发公司使用的组织 以下是我所指的代码模板: {@context”:http://schema.org", “@type”:“组织”, “名称”:“公司名称”, “法定名称”:“法定名称”, “url”:“公司url”, “徽标”:“内部徽标链接”, “成立日期”:“成立日期”, “创始人”:[ { “@type”:“Perso

我最近开始为一家美容公司工作,他想为他们的产品页面实现丰富的代码片段。我知道Schema.org标记是如何工作的,因为我复制了一个通用的
组织
,一个我的朋友为一家移动应用开发公司使用的组织

以下是我所指的代码模板:


{@context”:http://schema.org",
“@type”:“组织”,
“名称”:“公司名称”,
“法定名称”:“法定名称”,
“url”:“公司url”,
“徽标”:“内部徽标链接”,
“成立日期”:“成立日期”,
“创始人”:[
{
“@type”:“Person”,
“姓名”:“创始人”
} ],
“地址”:{
“@type”:“PostalAddress”,
“街道地址”:“街道地址”,
“地址地点”:“城市”,
“地址区域”:“区域”,
“邮政编码”:“邮政编码”,
“地址国家”:“联合王国”
},
“接触点”:{
“@type”:“联系人”,
“联系人类型”:“客户支持”,
“电话”:“电话号码”,
“电子邮件”:“电子邮件联系人”
},
“sameAs”:[
“社交媒体链接”
]}
不幸的是,这家公司的网站是基于Shopify的

在我没完没了的研究中,我遇到了许多不同的网站和博客,它们告诉我只需将这个
脚本
添加到
主题.liquid
文件中,但我找不到正确实现它的方法

你们有没有人有过这方面的经验,或者我应该联系Shopify的开发者,让他来做这项工作

我已经尝试过使用这个代码模板(我只是简单地复制并粘贴到liquid文件中):


{
“@context”:”http://schema.org/",
“@type”:“产品”,
“名称”:“{product.title}}”,
“sku”:“{product.variants.first.sku}”,
“gtin14”:“{product.variants.first.barcode}”,
“品牌”:“{product.vendor}}”,
“描述”:“{product.description | strip_html | escape}”,
“图片”:“https:{{product.featured_image.src}img_url:'grande'}”,
“提议”:{
“@type”:“Offer”,
“价格货币”:“{shop.currency}}”,
“价格”:“{product.price | money |不带| currency | strip | html}”,
“项目条件”:http://schema.org/NewCondition",
“可用性”:“{%if product.available==true%}http://schema.org/InStock{%else%}http://schema.org/OutOfStock{%endif%}“,
“url”:“{shop.url}}{{product.url}}”
}
}

我不明白什么不适合你

如文章所述,将其放入
theme.liquid
文件中

但是不要仅仅放置产品模式,当它不在产品模板上时,会导致大量错误,因为
{{product.title}
不会呈现任何内容;使用模板if语句获取索引、产品和文章的结果

下面是一个完整的工作示例:

<script type="application/ld+json">
{%- if template == 'index' -%}
{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "name": "{{ shop.name }}",
  "alternateName": "{{ shop.description }}",
  "url": "{{ shop.url }}"
}
{%- elsif template == 'product' %}
{
  "@context": "http://schema.org",
  "@type": "Product",
  "description": "{{ product.description | strip_html }}",
  "name": "{{ product.title }}",
  "image": "{{ product.featured_image | img_url: 'master' }}",
  "manufacturer": "{{ product.vendor }}",
  "category": "{{ collection.title }}",
  "sku": "{{ product.selected_or_first_available_variant.sku }}",
  "url": "{{ shop.url | append: product.url }}",
  "offers": {
    "@type": "Offer",
    "availability": "InStock",
    "price": "{{ product.price | money_without_currency }}",
    "priceCurrency": "{{ shop.currency }}"
  }
}
{%- elsif template == 'article' %}
{
  "@context": "http://schema.org",
  "@type": "NewsArticle",
  "image": {
    "@type": "imageObject",
    "url": "https:{{ article.image.src | img_url: 'original' }}",
    "width": "1024px",
    "height": "1024px"
  },
  "keywords": "{%- for tag in article.tags -%}{{ tag }}{%- unless forloop.last -%}, {%- endunless -%}{%- endfor -%}",
  "url": "{{ shop.url | append: article.url }}",
  "description": "{{ article.content | truncatewords: 100 | strip_html }}",
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://google.com/article"
  },
  "headline": "{{ article.title }}",
  "datePublished": "{{ article.published_at }}",
  "dateModified": "{{ article.published_at }}",
  "author": {
    "@type": "Person",
    "name": "{{ article.author }}"
  },
  "publisher": {
    "@type": "Organization",
    "name": "{{ shop.name }}",
    "logo": {
      "@type": "ImageObject",
      "url": "{{ shop.url }}"
    }
  },
  "commentCount": "{{ article.comments_count }}"
}
{%- endif %}
</script>

{%-如果模板=='index'-%}
{
“@context”:”http://schema.org",
“@type”:“网站”,
“名称”:“{shop.name}}”,
“alternateName”:“{shop.description}}”,
url:“{shop.url}}”
}
{%-elsif模板=='产品'%}
{
“@context”:”http://schema.org",
“@type”:“产品”,
“说明”:“{product.description | strip_html}}”,
“名称”:“{product.title}}”,
“图像”:“{product.characterized_image|img_url:'master'}}”,
“制造商”:“{product.vendor}}”,
“类别”:“{collection.title}}”,
“sku”:“{product.selected_或_first_available_variant.sku}”,
“url”:“{shop.url | append:product.url}}”,
“提议”:{
“@type”:“Offer”,
“可用性”:“InStock”,
“价格”:“{product.price}货币{u不含货币}”,
价格货币“{shop.currency}}”
}
}
{%-elsif template=='项目'%}
{
“@context”:”http://schema.org",
“@type”:“新闻文章”,
“图像”:{
“@type”:“imageObject”,
“url”:“https:{{article.image.src|img_url:'原始'}}”,
“宽度”:“1024px”,
“高度”:“1024px”
},
“关键字”:“{%-对于article.tags-%}{{tag}}{%-除非forloop.last-%},{%-end除非-%}{%-endfor-%}”,
“url”:“{shop.url | append:article.url}}”,
“说明”:“{article.content | truncatewords:100 | strip_html}”,
“页面维护”:{
“@type”:“网页”,
“@id”:”https://google.com/article"
},
“标题“{article.title}}”,
“datePublished”:“{article.published_at}”,
“dateModified”:“{article.published_at}”,
“作者”:{
“@type”:“Person”,
“名称:“{{article.author}}”
},
“出版商”:{
“@type”:“组织”,
“名称”:“{shop.name}}”,
“徽标”:{
“@type”:“ImageObject”,
url:“{shop.url}}”
}
},
“commentCount”:“{article.comments_count}”
}
{%-endif%}

谢谢!正是我想要的