验证错误:"指定了itemprop属性,但该元素不是任何项的属性"

29

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

这里是来源

然后我在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">
我该如何修复这个问题?

请注意,如果值是一个URL,则必须使用link元素(而不是meta)。因此,您的第三个meta元素应该是这样的:<link itemprop="image" href="http://www.example.com/image.jpg"> - unor
2个回答

41

这些属性(namedescriptionimage)所属的类型应明确指定。

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

例如:WebPageArticle或者BlogPosting

它可能看起来像这样(以使用WebPage为例):

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

谢谢您的回答。请分享如何在网页中使用模式添加国家代码和邮政地址。 - Jomal Johny
1
@JomalJohny:这里不是正确的地方。如果您在实现过程中遇到问题,请提出问题并详细描述问题。 - unor

3

如果您在网站标题、描述等处使用itemprop元标签,只需要在html标签中添加itemscope itemtype="http://schema.org/WebPage"即可。

用法:

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接