复制或链接到网站 JSON-LD? [英] Duplicate or link to WebSite JSON-LD?

查看:37
本文介绍了复制或链接到网站 JSON-LD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 JSON-LD 替换我们网站上的微数据(itemscope 等).我需要在每个页面上都声明WebSite,还是可以在首页上放置一次?

I'm replacing the microdata (itemscope et al) on our sites with JSON-LD. Do I need to declare the WebSite on every page, or can I place it once on the home page?

如果是后者,处理器(我的意思是谷歌)是否会通过域名自动将每个页面与其相关联,或者有什么方法可以链接到它?鉴于关联数据"就在名称中,我没有找到使用它的示例.它们都将数据直接复制或嵌入到正在链接的事物中.

If the latter, will processors (by which I mean Google) tie each page to it automatically via the domain name, or is there some way to link to it? Given that "Linked Data" is right there in the name, I've found no examples that make use of it. They all replicate or embed the data directly in the thing that's linking.

例如,我想链接到我们嵌入在文章中的 YouTube 视频,但 Google 无法识别 video 属性的 URL.如果我将其扩展为 VideoObject,Google 会抱怨我不知道宽度、高度、持续时间等.所有这些数据都在 youtube.com 的 URL 上我在指定.为什么不能自己拉取视频信息?

For example, I want to link to our YouTube videos that we embed in articles, but Google doesn't understand a URL for the video property. If I expand it into a VideoObject, Google complains that I don't know the width, height, duration, etc. All that data is on youtube.com at the URL I'm specifying. Why can't it pull the video information itself?

推荐答案

我需要在每个页面上都声明WebSite,还是我可以在主页上放置一次?

Do I need to declare the WebSite on every page, or can I place it once on the home page?

从 Schema.org 和关联数据的角度来看,只提供一个项目一次,并在需要时通过其 URI 引用它是完全没问题的(我认为这甚至是最佳实践).

From the perspectives of Schema.org and Linked Data, it’s perfectly fine (and I would say it’s even the best practice) to provide an item only once, and reference it via its URI whenever it’s needed.

在 JSON-LD 中,这个 可以通过 @id 完成.例如:

In JSON-LD, this can be done with @id. For example:

<!-- on the homepage -->
<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "@id": "http://example.com/#site",
  "hasPart": {
    "@type": "WebPage",
    "@id": "http://example.com/"
  }
}
</script>

<!-- on another page -->
<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebPage",
  "@id": "http://example.com/foobar",
  "isPartOf": {"@id": "http://example.com/#site"}
}
</script>

Google 是否真的遵循这些参考资料尚不清楚(据我所知,它没有记录)¹.很明显,他们的测试工具没有显示来自引用 URI 的数据,但这并不意味着什么.如果提供了 URI,至少他们的测试工具会显示 URI(作为ID").

Whether Google actually follows these references is not clear (as far as I know, it’s undocumented)¹. It’s clear that their testing tool doesn’t show the data from referenced URIs, but that doesn’t have to mean much. At least their testing tool displays the URI (as "ID") in case one is provided.

如果您想为 video 属性提供 URL 值,请注意URL 不是它的预期值之一.虽然 Schema.org 仍然允许这样做(任何属性都可以有文本或 URL 值),但一些消费者可能只会处理预期值.如果您只提供 值,也可以提供 VideoObject 值url 属性.Google 的测试工具给出错误的事实并不意味着有问题;这只是意味着 Google 不会因为与视频相关的富媒体搜索结果而考虑该视频.

If you want to provide a URL value for the video property, note that URL is not one of its expected values. While Schema.org still allows this (any property can have a text or URL value), it’s likely that some consumers will handle only expected values. It’s also perfectly fine to provide a VideoObject value if you only provide a url property. The fact that Google’s testing tool gives errors doesn’t mean that something’s wrong; it just means that Google won’t consider this video for their video-related rich results.

¹ 但对于 Google 提供的少数富媒体搜索功能,我猜作者通常不需要从其他页面引用某些内容.URI 的引用通常用于其他语义 Web 和关联数据案例.

¹ But for the few rich result features Google offers, authors would typically not need to reference something from another page anyway, I guess. Referencing of URIs is typically done for other Semantic Web and Linked Data cases.

这篇关于复制或链接到网站 JSON-LD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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