类型为“组织”的网页上的“ mainEntityOfPage”和“ CreativeWork”用法

时间:2019-02-27 18:27:02

标签: schema.org microdata

在这种情况下,我对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>

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

Result of the code validation on Structured Data Testing Tool

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

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

那么,这段代码告诉搜索引擎页面是Organization,在单独的页面上有3篇文章,还是只有Organization类型?

1 个答案:

答案 0 :(得分:0)

您的结构化数据未传达您要传达的内容。就是说Organization是三个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>

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

²微数据(与RDFa和JSON-LD相比)仅提供了一种非标准化的方式来在另一个方向上使用这些属性:see this answer

相关问题