适用于小公司的 Schema.org 实践:每个页面上的 JSON-LD 格式的“组织”和“网站”,其他所有内容的微数据

use*_*456 2 microdata schema.org json-ld

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

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

<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>
Run Code Online (Sandbox Code Playgroud)

然后我在 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>
Run Code Online (Sandbox Code Playgroud)

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

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

uno*_*nor 5

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

连接WebSiteOrganization

说到连接实体,我建议为您WebSiteOrganization项目执行此操作。例如,你可以指出你OrganizationpublisherWebSite,和/或该WebSiteaboutOrganization

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

  • 使用一个script元素并将Organization节点作为值嵌入
  • 保留两个script元素(或一个script元素 with@graph),给每个节点一个 URI(with @id)并将这些 URI 作为值引用

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

前一种方式的示例:

<script type="application/ld+json">
{
   "@context"          : "http://schema.org",
   "@type"             : "WebSite",
   "publisher"         : {
       "@type"         : "Organization"
   }
}
</script>
Run Code Online (Sandbox Code Playgroud)

后一种方式的示例:

<script type="application/ld+json">
{
    "@context"          : "http://schema.org",
    "@type"             : "Organization",
    "@id"               : "/#org"
}
</script>
Run Code Online (Sandbox Code Playgroud)
<script type="application/ld+json">
{
    "@context"          : "http://schema.org",
    "@type"             : "WebSite",
    "publisher"         : {"@id": "/#org"},
    "about"             : {"@id": "/#org"},
    "mainEntity"        : {"@id": "/#org"},
    "author"            : {"@id": "/#org"}
}
</script>
Run Code Online (Sandbox Code Playgroud)

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

提供 WebPage

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

如果您想提供这样的项目,SearchResultsPage在适用的情况下使用更具体的类型(如)当然更可取。但如果这是不可能的,那么WebPage到处使用总比不提供它好得多。

在您的情况下,您必须决定以哪种语法提供它。JSON-LD将允许您提供它hasPart的的WebSite根据前者的方式,上面解释的那样。但这会使WebPage通过mainEntity属性将与页面的主要实体(您在微数据中指定)连接起来变得困难。因为我认为这是一个重要的关系,所以我会WebPage在 Microdata 中指定 the并连接 theWebSiteWebPagevia URI。

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

"hasPart"           : {"@id": "/current-page.html"}
Run Code Online (Sandbox Code Playgroud)

(你也可以做到这一点从WebPage与逆属性微观数据isPartOf,但随后你就必须提供@idWebSite。)

具有WebPage微观数据,例如,在body元素,它可以让你提供的mainEntity属性:

<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>
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)

连接WebPageOrganization

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

<link itemprop="author publisher" href="/#org" />
Run Code Online (Sandbox Code Playgroud)

(可以推导出来,因为您声明了这一点,WebSite并且每个WebPage都通过 连接hasPart,但这对许多消费者来说可能太先进了,因此明确说明可能会有所帮助。)