微数据,RDFa或JSON-LD适当或最佳用法? [英] Microdata, RDFa or JSON-LD Appropriate or best usage?

查看:138
本文介绍了微数据,RDFa或JSON-LD适当或最佳用法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直想知道哪种格式是最佳"的? Schema.org,Microdata和RDFa实施起来有些麻烦.他们可能会破坏验证,并需要付出相当大的努力才能将其放入文档中.

I have been wondering which of those formats is "best"? Schema.org, Microdata, and RDFa are bit of a pain to implement. They can break validation and require quite an effort to put into documents.

JSON-LD是更好地实现结构化数据的一种方法.但这行得通吗? (至少由Google提供)什么级别的支持?

JSON-LD is, at last for me, a way better to implement structured data. But does it work? What level of support is there for it (at least by Google)?

推荐答案

Schema.org是一个词汇表,可以像其他任何词汇表一样以多种形式使用.网站 http://schema.org/包含使用 Microdata 和RDF语法 RDFa JSON-LD ,但这并不是它们可以使用的唯一语法.例如,您可以将其与任何其他 RDF 语法(如 Turtle )一起使用>或 RDF/XML .

Schema.org is a vocabulary that can, like any other vocabulary, be used in many forms. The website http://schema.org/ has examples using Microdata and the RDF syntaxes RDFa and JSON-LD, but these are not the only syntaxes it can be used with. You could, for example, use it with any other RDF syntax like Turtle or RDF/XML.

没有 best 语法.它们都有优点和缺点.例如,请参阅我关于 Microdata与RDFa之间的差异的答案.请注意,您可以在同一文档中使用不同的语法(和词汇表).

There is no best syntax. They all have advantages and disadvantages. See for example my answer about differences between Microdata and RDFa. Note that you can use different syntaxes (and vocabularies) in the same document.

现在,如果您有一个特定的消费者,则应查阅其文档.但是,语法的支持来了又去了,并不是它们可能支持的所有内容都必须记录在案,而且记录下来的所有内容也不一定行得通.

Now, if you have a specific consumer in mind, you should consult their documentation. However, support of syntaxes comes and goes, and not everything they might support is necessarily documented, and not everything that is documented necessarily works.

如果是Google,您可能会对他们的丰富网页摘要感兴趣.他们的有关丰富网页摘要的文档中提到了微数据,微格式和RDFa.但是,请注意,并非所有链接的示例都使用Schema.org词汇,而是使用较旧的Data-vocabulary.org或Microformats(因为您无法将Schema.org或Data-vocabulary.org等词汇与Microformats一起使用).此外,该页面上还没有列出一些Rich代码段,例如网站链接搜索框,甚至建议使用JSON-LD语法.

In case of Google, you are probably interested in their Rich Snippets. Their documentation about Rich Snippets mentions Microdata, Microformats and RDFa. However, note that not all linked examples use the Schema.org vocabulary, but the older Data-vocabulary.org or Microformats (as you can’t use vocabularies like Schema.org nor Data-vocabulary.org with Microformats). And there are also some Rich Snippets that aren’t listed on that page, like the Sitelinks Search Box, for which they even recommend the JSON-LD syntax.

作为一般建议:搜索引擎通常更喜欢可见内容而不是隐藏元数据.例如,将关键字作为隐藏的元数据可以轻松地使作者断言他们的文档与实际存在的事物有所不同(要么是因为试图欺骗搜索引擎,要么是因为作者忘记了同时更新 中的内容) >地方).因此,将元数据从内容中分离出来,就像JSON-LD一样,可能(可能!)会导致当前搜索引擎隐藏元数据的问题. ((如果或实际上哪个搜索引擎会像这样处理这个问题,这在Stack Overflow上是不合时宜的.)

As general advice: Search engines typically favor visible content over hidden metadata. For example, having keywords as hidden metadata easily allows authors to claim that their documents are about something different than they really are (either because of trying to trick the search engine, or because authors forget to update content in both places). Therefore, uncoupling the metadata from the content, like it’s the case with JSON-LD, could (possibly!) lead to the same issues current search engines have with hidden metadata. (If or which search engines actually handle it like that is a question which is off-topic on Stack Overflow.)

将元数据与内容(例如,使用RDFa)耦合的另一个可能的优点是,由于所有内容都是RDF,因此您可以轻松,自动地在JSON-LD,Turtle等中生成相同的信息.只需解析RDFa,将其转换为您喜欢的格式,然后在有意义的情况下嵌入(在script中)或链接(使用rel-alternate).

Another possible advantage for coupling the metadata with the content (for example, with RDFa), is that you could easily and automatically generate the same information in JSON-LD, Turtle etc. because everything’s just RDF. Just parse the RDFa, convert to formats of your preference, and embed (in script) or link (with rel-alternate) it if it makes sense.

但是,是的,添加RDFa通常比添加JSON-LD blob更复杂,因为您必须使它适应现有的标记. (但是,除非您犯了错误,否则不应破坏验证".)

But yes, adding RDFa is often more complex than adding a JSON-LD blob, because you have to adapt it to the existing markup. (However, it should not "break validation" unless you’re making mistakes.)

这篇关于微数据,RDFa或JSON-LD适当或最佳用法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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