适用于小公司的 Schema.org 实践:每个页面上的 JSON-LD 格式的“组织"和“网站",其他所有内容的微数据 [英] Schema.org practices for small company: 'Organization' and 'WebSite' in JSON-LD on every page, Microdata for everything else

查看:46
本文介绍了适用于小公司的 Schema.org 实践:每个页面上的 JSON-LD 格式的“组织"和“网站",其他所有内容的微数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何构建我的 Schema.org.我对 JSON-LD 和微数据元素使用混合方法.我不使用它们以两种不同的方式来描述一件事.我需要一些关于包含哪些内容的指南.

I'm wondering how to build my Schema.org. I'm using mixed approach with both JSON-LD and Microdata elements. I don't use them to describe one thing in 2 different ways. I need some guidelines about what to include.

现在我在每一页都有对我们公司的描述:

For now I have description of our company on every page:

<script type="application/ld+json">
{
    "@context"          : "http://schema.org",
    "@type"             : "Organization",
    "url"               : "https://our.url",
    "logo"              : "https://our.url/logo2.svg",
    "contactPoint"      : [{
        "@type"         : "ContactPoint",
        "telephone"     : "",
        "contactType"   : "Customer Service"
    }],
    "sameAs"            :[],
    "name"              : "Our Small Company"
}
</script>

我再次用 JSON-LD 对我们的网页进行了简短的描述:

Than I have a small description of our webpage again in JSON-LD:

<script type="application/ld+json">
{
   "@context"          : "http://schema.org",
    "@type"             : "WebSite",
    "url"               : "http://our.url",
    "potentialAction"   : {
        "@type"         : "SearchAction",
        "target"        : "http://our.url/search",
        "query-input"   : "required name=search_term_string"
    }
}
</script>

从这里开始,我拥有所有元素的微数据.例如,搜索结果是带有产品等的 ItemList.

And from here after I have Microdata for all elements. For example search results are ItemList with products, etc.

这看起来好吗?我应该在每个页面上包含 JSON-LD 公司描述还是只在主页上包含或根本不包含?我是否需要深入挖掘并为每个页面提供更具体的描述(例如搜索页面可以是 SearchResultsPage 而不是 WebSite)?

Does this seem Ok? Should I include JSON-LD company description on every page or only on the home page or not at all? Do I need to dig down and provide more specific description for every page (for example search page could be SearchResultsPage instead of WebSite)?

推荐答案

提供一些 JSON-LD 中的数据和 Microdata 中的一些数据应该没问题(但如果两者都是相同的实体,你 应该明确表示这一点).但是,如果您想连接实体,这可能会出现问题.

Providing some data in JSON-LD and some data in Microdata should be fine (but if both were about the same entities, you should denote this explicitly). It can become problematic if you want to connect the entities, though.

说到连接实体,我建议为您的 WebSiteOrganization 项目执行此操作.例如,您可以声明您的OrganizationpublisherWebSite 的一个>,和/或 WebSite<代码>关于组织.

Speaking of connecting entities, I would recommend to do this for your WebSite and Organization items. For example, you could state that your Organization is the publisher of the WebSite, and/or that the WebSite is about the Organization.

在 JSON-LD 中有两种方法可以实现这一点:

There are two ways how to achieve this in JSON-LD:

  • 使用一个script元素并将Organization节点作为值嵌入
  • 保留两个 script 元素(或一个带有 script 元素@graph),给每个节点一个 URI(带有 @id)并将这些 URI 作为值引用
  • use one script element and embed the Organization node as value
  • keep both script elements (or one script element with @graph), give each node a URI (with @id) and reference these URIs as values

前者可能有更好的消费者支持,后者更适合提供多个属性(例如,authorpublisher)而不必复制整个数据(但你也可以使用混合方式).

The former probably has better consumer support, the latter makes it more suitable to provide multiple properties (e.g., author and publisher) without having to duplicate the whole data (but you could use a mixed way, too).

前一种方式的例子:

<script type="application/ld+json">
{
   "@context"          : "http://schema.org",
   "@type"             : "WebSite",
   "publisher"         : {
       "@type"         : "Organization"
   }
}
</script>

后一种方式的例子:

<script type="application/ld+json">
{
    "@context"          : "http://schema.org",
    "@type"             : "Organization",
    "@id"               : "/#org"
}
</script>

<script type="application/ld+json">
{
    "@context"          : "http://schema.org",
    "@type"             : "WebSite",
    "publisher"         : {"@id": "/#org"},
    "about"             : {"@id": "/#org"},
    "mainEntity"        : {"@id": "/#org"},
    "author"            : {"@id": "/#org"}
}
</script>

(其中 /#org 是代表组织本身的 URI,而不仅仅是关于组织或组织的页面/站点)

(where /#org is the URI that represents the organization itself, not just a page/site about or of the organization)

您可以为每个页面提供一个 WebPage 项目.它在许多情况下都会有所帮助.但与任何其他类型的情况一样,没有任何要求.

You can provide a WebPage item for each page. It can be helpful in many situations. But like it’s the case with any other type, too, there is no requirement whatsoever.

如果您想提供这样的项目,当然最好使用更具体的类型(如 SearchResultsPage).但是,如果这是不可能的,那么在任何地方使用 WebPage 总比不提供所有内容要好.

If you want to provide such an item, using the more specific types (like SearchResultsPage) where applicable is of course preferable. But if that’s not possible, using WebPage everywhere is way better than not providing it all.

在您的情况下,您必须决定以哪种语法提供它.JSON-LD 允许您将其作为 WebSite 的 hasPart 提供 根据前一种方式,如上所述.但这会使通过 mainEntity 属性.由于我认为这是一个重要的关系,我会在 Microdata 中指定 WebPage 并通过 URI 连接 WebSiteWebPage.

In your case, you would have to decide in which syntax to provide it. JSON-LD would allow you to provide it as hasPart of the WebSite according to the former way, as explained above. But that would make it hard to connect the WebPage with your page’s main entity (which you specify in Microdata) via the mainEntity property. As I think this is an important relation, I would specify the WebPage in Microdata and connect the WebSite and the WebPage via URIs.

您可以从 JSON-LD WebSite 节点执行此操作:

You could do this from the JSON-LD WebSite node with:

"hasPart"           : {"@id": "/current-page.html"}

(您也可以从具有反向属性 isPartOf 的 WebPage 微数据中执行此操作,但随后您必须@id 提供@id代码>网站.)

(You could also do this from the WebPage Microdata with the inverse property isPartOf, but then you’d have to provide an @id for the WebSite.)

在微数据中有 WebPage,例如,在 body 元素上,它允许您提供 mainEntity 属性:

Having the WebPage in Microdata, e.g., on the body element, it allows you to provide the mainEntity property:

<body itemscope itemtype="http://schema.org/WebPage">
  <article itemprop="mainEntity" itemscope itemtype="http://schema.org/Article">
    <!-- for an article that is the main content of the page -->
  </article>
</body>

<body itemscope itemtype="http://schema.org/SearchResultsPage">
  <ul itemprop="mainEntity" itemscope itemtype="http://schema.org/ItemList">
    <!-- for a search result list that is the main content of the page -->
  </ul>
</body>

连接网页组织

如果您愿意,您可以明确声明 Organizationpublisher/author/etc.WebPage 也是:

Connecting WebPage and Organization

If you prefer, you could explicitly state that the Organization is the publisher/author/etc. of the WebPage, too:

<link itemprop="author publisher" href="/#org" />

(可以推断,因为您为 WebSite 声明了这一点,并且每个 WebPage 都通过 hasPart 连接,但这可能太高级了对于许多消费者而言,因此明确说明可能会有所帮助.)

(It could be deduced because you state this for the WebSite and every WebPage is connected via hasPart, but this is probably too advanced for many consumers, so stating it explicitly could help.)

这篇关于适用于小公司的 Schema.org 实践:每个页面上的 JSON-LD 格式的“组织"和“网站",其他所有内容的微数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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