JSON-LD和微数据在同一页面上? [英] JSON-LD and Microdata on the same page?

查看:76
本文介绍了JSON-LD和微数据在同一页面上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在电子商务产品页面上同时具有Micro Data和JSON-LD,描述的是同一件事(以我为例的产品).由于超出此问题范围的原因,我无法删除这两种格式中的任何一种.我想知道:

I have both Micro Data and JSON-LD on my e-commerce product pages, describing the same thing (products in my case). For reasons beyond the scope of this question, I cannot remove either of the two formats. I am wondering:

  1. 这是Google的问题吗?结构化数据测试工具确实显示了两个项目(产品),而不是一个.

  1. Is this a problem for Google? The structured data testing tool does display two items (products) instead of one.

如果一种属性(例如产品名称)在两种格式之间略有不同,那么两种格式(例如JSON-LD)中的任何一种都优先吗?

If one property, let's say the name of the product, is slightly different between the two formats, would any of the two formats, for example, JSON-LD take priority?

推荐答案

问题是,消费者会认为描述了不同事物(或更准确地说:消费者不会知道事物是否相同).

The problem is that a consumer would think that different things are described (or more accurately: the consumer wouldn’t know if the things are the same or not).

有一种防止这种情况发生的方法¹:为每件事物提供URI ,并且万一这些东西是相同,相同的URI.

There is a way to prevent this¹: give each thing a URI, and in case the things are the same, the same URI.

这可以通过JSON-LD中的@id和微数据中的itemid完成.

This can be done with @id in JSON-LD, and with itemid in Microdata.

一个简单的例子可能是:

So a simple case could be:

<!-- markup on the product page, 
     so the fragment "#this" results in an absolute URI like 
     "http://example.com/products/foo#this" -->

<!-- JSON-LD -->
<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Product",
  "@id": "#this",
  "name": "Foo"
}
</script>

<!-- Microdata -->    
<article itemscope itemtype="http://schema.org/Product" itemid="#this">
  <h1 itemprop="name">Foo</h1>
</article>

如果像name这样的属性具有不同的值,则消费者可以使用的明显方法是为其赋予多个名称.对于消费者仅需要一个名称(例如,以富裕结果表示)的功能,未定义将使用哪个name值.如果消费者是搜索引擎,则可能会使用其现有的专有算法来处理此类情况.

In case a property like name has different values, the obvious way a consumer could handle this is to give the thing multiple names. For a feature where the consumer needs exactly one name (e.g., in a rich result), it’s not defined which of the name values will be used. If the consumer is a search engine, it will likely use its already existing proprietary algorithms to handle such cases.

¹当然,尚不清楚所有消费者是否/如何支持它.但这是执行此操作的正确方法,也是执行此操作的唯一明确方法.隐式方式包括希望消费者理解通常(但不是必须)唯一属性(例如urlemailproductID等)的相同值表示事物相同.但是,当然可以将这种隐式方式与显式方式一起使用.

¹ Of course it’s not clear if/how all the various consumers support it. But it’s the correct way to do this, and it’s the only explicit way to do this. Implicit ways include hoping that a consumer understands that identical values for typically (but not necessarily) unique properties (e.g., url, email, productID, etc.) mean that the things are the same. But such an implicit way can of course be used together with the explicit one.

这篇关于JSON-LD和微数据在同一页面上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆