微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html – 如何在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.</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.</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.</p>
    </body>
</html>

第一段显然是关于这个人,John Doe,第二段是关于一家公司,即MITR公司.但第一段中的“MITR”与第二届“MITR公司”相同.如何使用schema.org明确声明这些是一样的?

解决方法

//更新:Schema.org扩展了perso架构的规范

显然,该人与本公司有关系,所以您可以做的是将人与机构之间的关系置于“人”之间的“propprop”
所以我做的是用itemscope itemtype =“Person”包装段落,并通过添加itemprop“affiliation”和itemscope itemtype =“Organization”扩展了Schema Person,所以现在是一个语义关系,该人员隶属于组织.
我还添加了itemprop =“name”的Meta标签,因为它需要满足“Person”规范

<!DOCTYPE HTML>
<html>
<head>
    <Meta charset="utf-8">
    <title>New Job for John Doe</title>
</head>
<body>
<div itemscope itemtype="http://schema.org/Person">
    <h1>New Job for John Doe</h1>
<Meta itemprop="name" content="John Doe" />
    <p>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.</p>
    <p itemprop="affiliation" itemscope itemtype="http://schema.org/Organization">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,blah.</p>
</div> <!-- closing Schema "Person" -->
</body>
</html>

您可以将其放入Google的丰富网页摘要测试工具,我猜输出是您要查找的内容

Item 
type:   http://schema.org/person
property:   
name:   John Doe
jobtitle:   Software Engineer
worksfor:   MITRE
alumniof:   MIT
affiliation: Item 1


Item 1
type:   http://schema.org/organization
property:   
location:   bedford,Massachusetts
location:   McLean,Virginia

原文地址:https://www.jb51.cc/html/230248.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐