gpt4 book ai didi

schema.org - 如何在此特定站点上实现“mainEntityOfPage”?

转载 作者:行者123 更新时间:2023-12-03 13:41:48 28 4
gpt4 key购买 nike

请在这里看看:https://developers.google.com/structured-data/testing-tool?url=https%253A%252F%252Fglamourina.net%252Fen%252F

如何将mainEntityOfPage正确添加到此站点?

在Google文档示例中,我看到了以下内容:



<div itemscope itemtype="http://schema.org/NewsArticle">

<meta itemscope itemprop="mainEntityOfPage" itemType="https://schema.org/WebPage" itemid="https://google.com/article"/>


但这是一个作者博客。它具有blogPosts。

<article itemscope itemtype="https://schema.org/BlogPosting" class="singlearticles">


如果我这样更改它会很好:

<article itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<meta itemscope itemprop="mainEntityOfPage" itemType="https://schema.org/WebPage" itemid="https://linktoarticle"/>


不知道我是否理解 mainEntityOfPage用法。如果有人可以建议我如何处理此特定案例/网站,将不胜感激。由于每个站点可以具有不同的 mainEntityOfPage,所以这不是一般性的,但是我需要了解和理解该站点的正确实现。

最佳答案

关于Google的微数据示例

Google的微数据示例无效。如果meta元素具有itemprop属性,则需要content属性(details)。

我描述了different ways how to specify mainEntityOfPage in Microdata,最直接的一个是创建URL值(而不是另一个Microdata项)的link元素:



<link itemprop="mainEntityOfPage" href="http://example.com/article-1" />


mainEntity

如果我们先看一下 mainEntityOfPage的逆属性 mainEntity,就更容易理解它的用法。

对于包含 WebPageBlogPosting,我们可以有:

<body itemscope itemtype="http://schema.org/WebPage">
<article itemprop="mainEntity" itemscope itemtype="http://schema.org/BlogPosting">
</article>
</body>


这意味着:有一个 WebPageBlogPosting,并且 BlogPosting是此 WebPage中描述的“主要实体”。如果涉及更多项,例如,用 Person描述作者,另外五个有关相关帖子的 BlogPosting项,提供某些元数据的 WebSite项等,则表示这一点特别有意义。感谢 mainEntity / mainEntityOfPage,消费者可以了解该页面上的主要/主要项目是什么(即页面代表什么)。

mainEntityOfPage

以下带有 mainEntityOfPage的示例将产生等效的结构化数据,就像上面带有 mainEntity的示例一样:

<article itemscope itemtype="http://schema.org/BlogPosting">
<div itemprop="mainEntityOfPage" itemscope itemtype="http://schema.org/WebPage">
</div>
</article>


如您所见, BlogPosting项的元素包含 WebPage项的元素。这当然是不寻常的标记。

但是 mainEntityOfPage属性不仅希望将( CreativeWork)项作为值,还希望使用URL。因此,您可以提供页面的URL,而不是显式提供 WebPage项:

<article itemscope itemtype="http://schema.org/BlogPosting">
<link itemprop="mainEntityOfPage" href="http://example.com/article-1" />
</article>


(这是Google期望的,根据他们的 Articles Rich Snippet文档。)

图表:页面与帖子的网址

许多网站无法区分网页的URL和博客文章的URL。对于这些网站,声明如下内容似乎很愚蠢

http://example.com/article-1 (the blog post)
is the 'mainEntityOfPage'
http://example.com/article-1 (the web page)


http://example.com/article-1 (the web page) 
has 'mainEntity'
http://example.com/article-1 (the blog post)


但这还是很有用的(例如,选择哪个项是主要项,因为其他项将没有此语句;或者对于空白节点等)。

但是,某些网站确实有所区别(尤其是 Linked Data),因此它们可能会声明类似

http://example.com/article-1#this (the blog post)
is the 'mainEntityOfPage'
http://example.com/article-1 (the web page)


http://example.com/article-1 (the web page) 
has 'mainEntity'
http://example.com/article-1#this (the blog post)


在这里, http://example.com/article-1#this代表博客发布,而 http://example.com/article-1代表具有有关此发布信息(或发布本身的内容)的页面。一个更清晰的例子是一个人和一个关于该人的页面;或一栋建筑物以及关于该建筑物的页面。请参阅我的答案以获取示例 why you might want to do this。 (但是,如上所述,您不必区分;您可以为两者使用相同的URL。)

关于schema.org - 如何在此特定站点上实现“mainEntityOfPage”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34466028/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com