首页 > 解决方案 > 在“组织”类型的网页上使用“mainEntityOfPage”和“CreativeWork”

问题描述

我有一个关于mainEntityOfPage在这种情况下正确使用 , 的问题:

  1. 该网站的主页是Organization带有名称、公司描述、电话、地址等的类型。
  2. 在这个页面的底部,我有这家公司发表的 3 篇不同文章的 3 个片段。
  3. 所以,我试图声明Organization类型的主页,作为网页的主题。另外,我想使用 Schema.org 声明这家公司已经写了 3 篇不同的文章,这些文章位于他们自己的网页上。这些片段由文章标题、介绍段落、图片和“阅读更多”按钮组成。

我使用以下代码:

<body itemscope itemtype="http://schema.org/Organization" >
<a href="https://testsite.com/index.html" itemprop="url">
<img src="https://testsite.com/img/logo.jpg" itemprop="logo" alt="Company logo" />
</a>
<p itemprop="name">Company name</p>
<p itemprop="description">Company description</p>

<div itemprop="mainEntityOfPage" itemscope itemtype="https://schema.org/CreativeWork">
<meta itemprop="thumbnailUrl" content="https://testsite.com/img/article-1-picture.jpg" />
<p itemprop="headline">Article 1 headline</p>
<p itemprop="description">Article 1 first paragraph.</p>
<a itemprop="url" href="https://testsite.com/url-article-1.html">Read more</a>
</div>

<div itemprop="mainEntityOfPage" itemscope itemtype="https://schema.org/CreativeWork">
<meta itemprop="thumbnailUrl" content="https://testsite.com/img/article-2-picture.jpg" />
<p itemprop="headline">Article 2 headline</p>
<p itemprop="description">Article 2 first paragraph.</p>
<a itemprop="url" href="https://testsite.com/url-article-2.html">Read more</a>
</div>

<div itemprop="mainEntityOfPage" itemscope itemtype="https://schema.org/CreativeWork">
<meta itemprop="thumbnailUrl" content="https://testsite.com/img/article-3-picture.jpg" />
<p itemprop="headline">Article 3 headline</p>
<p itemprop="description">Article 3 first paragraph.</p>
<a itemprop="url" href="https://testsite.com/url-article-3.html">Read more</a>
</div>
</body>

上面的代码生成以下架构:

结构化数据测试工具的代码验证结果

该代码对结构化数据测试工具有效。

恐怕mainEntityOfPage在这里使用3次来介绍文章片段会导致搜索引擎错误地认为我的页面类型CreativeWork而不是Organization类型,这才是这个网页上真正的主题。

那么,这段代码告诉搜索引擎该页面是Organization在单独的页面上包含 3 篇文章,还是只CreativeWork输入?

标签: schema.orgmicrodata

解决方案


您的结构化数据没有传达您打算传达的内容。就是说是三个sOrganization上的主要实体。CreativeWork

所以,我试图声明Organization类型的主页,作为网页的主题。

为此,您需要一个WebPage代表主页的项目。

<body itemscope itemtype="http://schema.org/Organization">

  <div itemprop="mainEntityOfPage" itemscope itemtype="http://schema.org/WebPage">
    <link itemprop="url" href="https://example.com/" /> <!-- the canonical URL of your homepage -->
  </div>

</body>

我想使用 Schema.org 声明这家公司已经写了 3 篇不同的文章,这些文章位于他们自己的网页上。

为此,您需要说明公司和文章¹如何相关的属性,例如:

请注意,例如,publisher只为一个方向定义(一篇文章有​​一个出版商),而不是为另一个方向定义(一个组织已经发表了一篇文章)。²所以您必须在 中提供此属性Article,而不是在Organization.

<article itemscope itemtype="http://schema.org/Article">

  <div itemprop="mainEntityOfPage" itemscope itemtype="http://schema.org/ItemPage">
    <link itemprop="url" href="https://example.com/url-article-1.html" /> <!-- the canonical URL of the article page -->
  </div>

  <div itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <link itemprop="url" href="https://example.com/" /> <!-- the canonical URL of the organization’s homepage -->
  </div>

</article>

¹如果它们实际上是文章,则应使用Article类型而不是父类型CreativeWork

² 微数据(与 RDFa 和 JSON-LD 相比)仅提供了一种非标准化的方式来在另一个方向使用这些属性:请参阅此答案


推荐阅读