我最近开始为一家美容公司工作,该公司希望为其产品页面实现丰富的摘要。我已经复制了我的朋友用于移动应用开发公司的通用Organization
,因此我知道Schema.org标记的工作原理。
这是我指的代码模板:
<script type="application/ld+json">
{ "@context": "http://schema.org",
"@type": "Organization",
"name": "Company name",
"legalName" : "Legal Name",
"url": "Company URL",
"logo": "internal logo link",
"foundingDate": "founding date",
"founders": [
{
"@type": "Person",
"name": "Founder"
} ],
"address": {
"@type": "PostalAddress",
"streetAddress": "Street Address",
"addressLocality": "City",
"addressRegion": "Region",
"postalCode": "Postcode",
"addressCountry": "United Kingdom"
},
"contactPoint": {
"@type": "ContactPoint",
"contactType": "customer support",
"telephone": "Phone Number",
"email": "email contact"
},
"sameAs": [
"Social Media Links"
]}
</script>
不幸的是,该公司的网站是基于Shopify的。
在无休止的研究过程中,我遇到了许多不同的站点和博客,它们告诉我只需将此script
添加到theme.liquid
文件中,但我找不到正确实现它的方法。 This is the blog post I was browsing。
你们中的任何人是否有任何经验,或者我应该联系Shopify开发人员并让他完成这项工作?
我已经尝试使用此代码模板(我只是将其复制并粘贴到液体文件中):
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": "{{ product.title }}",
"sku": "{{ product.variants.first.sku }}",
"gtin14": "{{ product.variants.first.barcode }}",
"brand": "{{ product.vendor }}",
"description": "{{ product.description | strip_html | escape }}",
"image": "https:{{ product.featured_image.src | img_url: 'grande' }}",
"offers": {
"@type": "Offer",
"priceCurrency": "{{ shop.currency }}",
"price": "{{ product.price |money_without_currency | strip_html }}",
"itemCondition" : "http://schema.org/NewCondition",
"availability" : "{% if product.available == true %}http://schema.org/InStock{% else %}http://schema.org/OutOfStock{% endif %}",
"url" : "{{ shop.url }}{{ product.url }}"
}
}
</script>
答案 0 :(得分:1)
我不明白什么不适合您?
就像文章所说的那样,将其放入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>