我正在尝试将 schema.org 标记添加到一家律师事务所的网站 (itemtype=schema.org/Attorney)。该站点包含一个专用于公司中每位律师的页面 (itemtype=schema.org/Person)。这些个人资料页面包括已发表作品的列表(例如 itemtype=schema.org/Book)。我想说明此人是该组织的成员和书籍的作者。我正在努力实现这一目标。
这是我正在使用的一些代码:
<body itemscope itemtype="http://schema.org/Attorney">
<!-- this stuff just so the Yandex validator doesn't freak out -->
<meta itemprop="name" content="some law firm">
<meta itemprop="address" content="some address">
<meta itemprop="telephone" content="555-555-5555">
<h1>Book Test</h1>
<div id="profile" itemscope itemtype="http://schema.org/Person">
<h1 itemprop="name">John Smith</h1>
<h3>Published Works</h3>
<ul>
<li itemscope itemtype="http://schema.org/Book"><span itemprop="name">Some Book</span><meta itemprop="author" itemref="profile"></li>
</ul>
</div>
<meta itemprop="member" itemref="profile">
</body>
在浏览器中查看 https://dl.dropboxusercontent.com/u/292741/schema-test-book-stackoverflow.html
使用 Google 的结构化数据工具 (google.com/webmasters/tools/richsnippets) 或 Yandex (webmaster.yandex.com/microtest.xml) 对此进行测试时,我没有得到想要的结果。在这种情况下,成员和作者属性没有注册。
我尝试了多种变体。以下是一些重要的:
如果我将 itemscope 和 itemtype=Person 放在 member 和 author 属性元标记上,则属性会注册,但工具认为我在谈论三个不同的人(就好像 itemref 没有注册一样)。
如果我将成员和作者属性放在#profile 上,它们会起作用,但我会收到错误消息,因为组织没有作者,书籍也没有成员。
这两者的结合只取得了部分成功。因此,将 just 成员属性放在 #profile 上并通过元标记执行 author 要么导致 author 属性被忽略(当我不给它自己的范围和 type=Person 时),要么它适用于一些与一个由#profile 定义的(当我给它它的 ow 范围等时)。
我也尝试过使用 schema.org/WriteAction 作为了解书与人之间关系的另一种方式,但我在那里遇到了同样的问题。我可以让 organization->member 或 writeaction->agent 工作,但不能同时工作。
这是我得到的结构(由 Google 的工具表示):
Item
type: schema.org/attorney
property:
name: some law firm
address: some address
telephone: 555-555-5555
member:
Item
type: schema.org/book
property:
name: Some Book
author:
Item
type: schema.org/person
property:
name: John Smith
我想要的结构(由 Google 的工具表示)是这样的:
Item
type: schema.org/attorney
property:
name: some law firm
address: some address
telephone: 555-555-5555
member: Item 1 <-- now references the person
Item
type: schema.org/book
property:
name: Some Book
author: Item 1 <-- now references the person
Item 1
type: schema.org/person
property:
name: John Smith
如果有任何建议,我将不胜感激。谢谢!
最佳答案
更新 (2016)
多类型实体的使用似乎在 Microdata 中迎头 catch ,因此在 Schema.org 中使用未为所有指定类型定义的属性(如我在下面的旧答案中所述)可能没问题。
无论如何,对标识符的支持(在微数据中:使用 itemid
)现在似乎更好(至少它在 Google 的测试工具中得到支持),这可能是适合您的情况的解决方案:
- 在
itemid
中给这个人一个 URI> - 将此 URI 引用为
author
和member
的值
例子:
<div itemscope itemtype="http://schema.org/Person" itemid="/team/alice#i">
</div>
<div itemscope itemtype="http://schema.org/LegalService">
<link itemprop="member" href="/team/alice#i" />
</div>
<div itemscope itemtype="http://schema.org/Book">
<link itemprop="author" href="/team/alice#i" />
</div>
请注意,Attorney
类型现已弃用,因此我在此示例中使用了 LegalService
。
旧答案(2014)
(请注意,您对 itemref
的使用不正确,因为它是 can only be used on elements with itemscope
。)
微数据无法做到这一点。
这将导致使用对其父项无效的属性(无论是通过嵌套还是通过 itemref
)itemtype:
您不能通过 itemref
为代理人和书籍引用人物,因为这需要使用 itemprop="author member"
(is valid Person 上的语法),但 author
不是 Attorney 的有效属性,member
不是 Book 的有效属性。
如果您将 Person 嵌套在 Book 下并使用 itemref
引用来自 Attorney 的同一个人,也会出现同样的问题。或相反亦然。
所以我只能看到重复的信息,很遗憾。
关于html - 我如何使用 schema.org 将一个人(无需重复)标记为组织成员和一本书的作者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21315574/