Validation error: "The itemprop attribute was specified, but the element is not a property of any item"

Validation error: "The itemprop attribute was specified, but the element is not a property of any item"

为了更好的 SEO,我需要像这样在我的页面上放置一些元数据:

<!-- Schema.org markup for Google+ -->
<meta itemprop="name" content="The Name or Title Here">
<meta itemprop="description" content="This is the page description">
<meta itemprop="image" content="http://www.example.com/image.jpg"> 

Here is the source.

然后我在 Markup Validation Service 上检查此代码:

<!DOCTYPE html>
<html>
<head lang="en">
  <meta itemprop="name" content="The Name or Title Here">
  <meta itemprop="description" content="This is the page description">
  <meta itemprop="image" content="http://www.example.com/image.jpg">
  <meta charset="UTF-8">
  <title>My title</title>
</head>
<body>
  My body.
</body>
</html>

抛出此错误:

Line 4, Column 57: The itemprop attribute was specified, but the element is not a property of any item.

 <meta itemprop="name" content="The Name or Title Here">

Line 5, Column 70: The itemprop attribute was specified, but the element is not a property of any item.

 <meta itemprop="description" content="This is the page description">

Line 6, Column 68: The itemprop attribute was specified, but the element is not a property of any item.

 <meta itemprop="image" content="http://www.example.com/image.jpg">

我该如何解决这个问题?

您应该明确提供一个 type 这些属性(namedescriptionimage)属于。

在Schema.org里,一切都是ThingThing 有许多子类型,列在 "More specific Types" 下。从那里开始,为您的内容选择最具体的类型。

例如:WebPage, Article or maybe BlogPosting.

它看起来像(这里使用 WebPage 作为示例):

<html itemscope itemtype="http://schema.org/WebPage">

如果您在 header 中使用 itemprop 元标记作为站点标题、描述等。

只需在 html tag 中添加 itemscope itemtype="http://schema.org/WebPage"

用法:

<html itemscope itemtype="http://schema.org/WebPage">