gpt4 book ai didi

html - 我如何关联 schema.org 中的项目?

转载 作者:技术小花猫 更新时间:2023-10-29 12:34:41 30 4
gpt4 key购买 nike

假设我有一个关于一个人找工作的简单 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 这个人,第二段是关于一家公司,The MITRE Corporation。但第一段中的“MITRE”与第二段中的“The MITRE Corporation”相同。我如何使用 schema.org 明确声明它们是一回事?

最佳答案

//更新:Schema.org 扩展了他们的个人模式规范

很明显这个人与公司有关,所以你可以做的是在人和组织之间建立关系,用“人”的项目 Prop “隶属关系”所以我所做的是用 itemscope itemtype="Person"包装段落并通过添加 itemprop"affiliation"和 itemscope itemtype="Organization"扩展 Schema Person 所以现在有语义关系,这个人隶属于组织。我还添加了带有 itemprop="name"的元标记,因为它需要满足“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, 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, Massachusetts</span>, and <span itemprop="location">McLean, Virginia</span>. Blah, blah, blah.</p>
</div> <!-- closing Schema "Person" -->
</body>
</html>

您可以将其放入 google rich snippet 测试工具中,我想输出就是您要查找的内容

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

关于html - 我如何关联 schema.org 中的项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7745955/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com