如何关联 schema.org 中的项目?
假设我有一个关于一个人找工作的简单 HTML 页面:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>New Job for John Doe</title>
</head>
<body>
<h1>New Job for John Doe</h1>
<p>This week John Doe accepted an offer to become a Software Engineer at MITRE. John graduated from MIT in 2005 with a BS in Computer Science. He previously worked at a small company near Boston. Blah, blah, blah.</p>
<p>The MITRE Corporation is a not-for-profit organization chartered to work in the public interest. The MITRE Corporation has two principal locations: Bedford, Massachusetts, and McLean, Virginia. Blah, blah, blah.</p>
</body>
</html>
如果我使用 schema.org 词汇表添加语义数据,它可能看起来像这样:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>New Job for John Doe</title>
</head>
<body>
<h1>New Job for John Doe</h1>
<p itemscope itemtype="http://schema.org/Person">This week John Doe accepted an offer to become a <span itemprop="jobTitle">Software Engineer</span> at <span itemprop="worksFor">MITRE</span>. John graduated from <span itemprop="alumniOf">MIT</span> in 2005 with a BS in Computer Science. He previously worked at a small company near Boston. Blah, blah, blah.</p>
<p itemscope itemtype="http://schema.org/Corporation">The MITRE Corporation is a not-for-profit organization chartered to work in the public interest. The MITRE Corporation has two principal locations: <span itemprop="location">Bedford, Massachusetts</span>, and <span itemprop="location">McLean, Virginia</span>. Blah, blah, blah.</p>
</body>
</html>
第一段显然是关于这个人 John Doe,第二段是关于MITRE 公司。但第一段中的“MITRE”与第二段中的“The MITRE Corporation”相同。如何使用 schema.org 显式声明它们是相同的?
Suppose I have this simple HTML page about a guy getting a job:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>New Job for John Doe</title>
</head>
<body>
<h1>New Job for John Doe</h1>
<p>This week John Doe accepted an offer to become a Software Engineer at MITRE. John graduated from MIT in 2005 with a BS in Computer Science. He previously worked at a small company near Boston. Blah, blah, blah.</p>
<p>The MITRE Corporation is a not-for-profit organization chartered to work in the public interest. The MITRE Corporation has two principal locations: Bedford, Massachusetts, and McLean, Virginia. Blah, blah, blah.</p>
</body>
</html>
If I add semantic data using the schema.org vocabulary, it might look like this:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>New Job for John Doe</title>
</head>
<body>
<h1>New Job for John Doe</h1>
<p itemscope itemtype="http://schema.org/Person">This week John Doe accepted an offer to become a <span itemprop="jobTitle">Software Engineer</span> at <span itemprop="worksFor">MITRE</span>. John graduated from <span itemprop="alumniOf">MIT</span> in 2005 with a BS in Computer Science. He previously worked at a small company near Boston. Blah, blah, blah.</p>
<p itemscope itemtype="http://schema.org/Corporation">The MITRE Corporation is a not-for-profit organization chartered to work in the public interest. The MITRE Corporation has two principal locations: <span itemprop="location">Bedford, Massachusetts</span>, and <span itemprop="location">McLean, Virginia</span>. Blah, blah, blah.</p>
</body>
</html>
The first paragraph is obviously about the person, John Doe, and the second paragraph is about a company, The MITRE Corporation. But the "MITRE" in the first paragraph is the same as "The MITRE Corporation" in the second. How do I explicitly declare these to be one and the same using schema.org?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
//更新:Schema.org扩展了他们的个人模式规范,
显然个人与公司相关,所以你可以做的是在个人和组织之间建立一个关系“person´s”itemprop“affiliation”
所以我所做的就是用 itemscope itemtype="Person" 包装段落,并通过添加 itemprop"affiliation" 和 itemscope itemtype="Organization" 来扩展 Schema Person,所以现在存在语义关系,该人隶属于该组织。
我还添加了带有 itemprop="name" 的元标记,因为它需要满足“Person”规范
您可以将其放入谷歌丰富的代码片段测试工具中,我猜输出就是您要寻找的内容
//Update : Schema.org expanded their specifications of perso schema
obviously the Person is related to the Company, so what you can do is to make a relation between person and organisation wit "person´s" itemprop "affiliation"
so what i did is wrapping the paragraphs with itemscope itemtype="Person" and expanded the Schema Person by adding itemprop"affiliation" and itemscope itemtype="Organization" so now theres a semantic relation, the person is affiliated with the organization.
I also added meta tag with itemprop="name" because it´s needed to fulfill "Person" specifications
You can put this into google rich snippet testing tool and i guess the Output is what you where looking for
我第一次尝试回答我自己的问题是使用 itemref 属性,如下所示:
但一些评论者正确地指出这不是该属性的正确用法。
这是我的第二次尝试:改用
itemid
属性。公司名称的两个实例都被赋予一个itemscope
和itemtype
属性,并且它们都设置为相同的itemid
值,该值是一个 URL 。规范说:“itemid 属性(如果指定)必须有一个值这是一个可能被空格包围的有效 URL...项目的全局标识符是其元素的 itemid 属性的值,如果有,则相对于指定该属性的元素进行解析...itemid 属性必须不能在不具有 itemscope 属性的元素上指定并指定了 itemtype 属性。”
My first attempt to answer my own question was to use the itemref attribute, like so:
But some of the commenters rightly pointed out this was not the right use of this attribute.
So here's my second attempt: Use the
itemid
attribute instead. Both instances of the company name are given anitemscope
anditemtype
attribute, and they are both set to the sameitemid
value, which is a URL.The spec says: "The itemid attribute, if specified, must have a value that is a valid URL potentially surrounded by spaces...The global identifier of an item is the value of its element's itemid attribute, if it has one, resolved relative to the element on which the attribute is specified...The itemid attribute must not be specified on elements that do not have both an itemscope attribute and an itemtype attribute specified."