是否可以将页面的元描述用作微数据?
问题描述:
我想知道如果像下面这样是很好..是否可以将页面的元描述用作微数据?
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Microdata Example</title>
<meta id="site-description" name="description" content="description text here">
</head>
<body itemscope itemref="site-description" itemtype="http://schema.org/Organization">
<h1 itemprop="name">Foo</h1>
<img itemprop="image" src="bar.jpg">
</body>
</html>
答
这是行不通的。
itemref
属性用于引用Microdata属性,但引用的meta
元素不具有itemprop
属性。
而且您不能将itemprop
属性添加到meta
元素if it has a name
attribute。
如果你不希望有这样的描述中可见的页面上,你可以
-
添加
meta
元素在head
,使用itemref
:<head> <meta name="description" content="description text here"> <meta id="site-description" itemprop="description" content="description text here"> </head> <body itemscope itemref="site-description" itemtype="http://schema.org/Organization"> </body>
-
添加
meta
元素在body
中,未使用itemref
:<head> <meta name="description" content="description text here"> </head> <body itemscope itemtype="http://schema.org/Organization"> <meta itemprop="description" content="description text here"> </body>
(假设你想使用Schema.org的description
property)
谢谢您的回答,我希望能找到不涉及添加描述两次的解决方案。猜猜这是不可能的。别担心 – shunryu111 2014-12-09 09:49:19