搜索结果中的微数据站点名称:"Attribute itemprop not allowed on element link at this point."
Microdata site name in search results: "Attribute itemprop not allowed on element link at this point."
From Google Developers 我以微数据为例,将站点名称包含在搜索结果中:
<head itemscope itemtype="http://schema.org/WebSite">
<title itemprop='name'>Your WebSite Name</title>
<link rel="canonical" href="https://example.com/" itemprop="url">
</head>
使用 W3C Validator 我收到此错误消息:
Error: Attribute itemprop not allowed on element link at this point.
正确的标记是什么?
根据 WHATWG 的 HTML,link
不能有 rel
和 itemprop
属性。根据 W3C 的 Microdata(这是一个不再更新的 Note),这两个属性可以一起使用。有关详细信息,请参阅我的问题 。
因此,如果您想同时符合这两个规范,则必须复制 link
元素:
<head itemscope itemtype="http://schema.org/WebSite">
<title itemprop="name">Your WebSite Name</title>
<link itemprop="url" href="https://example.com/">
<link rel="canonical" href="https://example.com/">
</head>
From Google Developers 我以微数据为例,将站点名称包含在搜索结果中:
<head itemscope itemtype="http://schema.org/WebSite">
<title itemprop='name'>Your WebSite Name</title>
<link rel="canonical" href="https://example.com/" itemprop="url">
</head>
使用 W3C Validator 我收到此错误消息:
Error: Attribute itemprop not allowed on element link at this point.
正确的标记是什么?
根据 WHATWG 的 HTML,link
不能有 rel
和 itemprop
属性。根据 W3C 的 Microdata(这是一个不再更新的 Note),这两个属性可以一起使用。有关详细信息,请参阅我的问题
因此,如果您想同时符合这两个规范,则必须复制 link
元素:
<head itemscope itemtype="http://schema.org/WebSite">
<title itemprop="name">Your WebSite Name</title>
<link itemprop="url" href="https://example.com/">
<link rel="canonical" href="https://example.com/">
</head>