【问题标题】:Validation error: "The itemprop attribute was specified, but the element is not a property of any item"验证错误:“指定了 itemprop 属性,但该元素不是任何项目的属性”
【发布时间】:2015-05-21 07:39:37
【问题描述】:

为了更好的 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>

抛出此错误:

第 4 行,第 57 列:指定了 itemprop 属性,但该元素不是任何项目的属性。

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

第 5 行,第 70 列:指定了 itemprop 属性,但该元素不是任何项目的属性。

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

第 6 行,第 68 列:指定了 itemprop 属性,但该元素不是任何项目的属性。

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

我该如何解决这个问题?

【问题讨论】:

标签: seo meta-tags w3c-validation schema.org microdata


【解决方案1】:

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

在 Schema.org 中,所有内容都是 ThingThing 有许多子类型,列在“更具体的类型”下。从那里开始,为您的内容选择最具体的类型。

例如:WebPageArticle 或者BlogPosting

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

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

【讨论】:

  • 感谢您的回答。并请分享如何在网页中使用架构添加国家代码和邮政地址
  • @JomalJohny:这里不适合。如果您在实施时遇到问题,请提出问题并详细描述问题。
【解决方案2】:

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

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

用法:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-05
    • 1970-01-01
    • 2016-11-12
    • 1970-01-01
    • 2011-02-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多