如何在 Schema.org 标记中将工作 (jobTitle) 与组织 (worksFor) 相关联? [英] How do I relate Job (jobTitle) to Organization (worksFor) in Schema.org markup?

查看:36
本文介绍了如何在 Schema.org 标记中将工作 (jobTitle) 与组织 (worksFor) 相关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Person 架构下,我想要 将每个职位与其各自的组织相关联.这是在类似简历的环境中,因此有许多工作和许多组织.

这是我的项目中的一些代码的实际示例(内容剪辑 + 更改):

…<p><!--作业列表--><span itemprop="jobTitle">作业 1</span>,<span itemprop="jobTitle">工作 2</span>,和<span itemprop="jobTitle">工作 3</span></p><p><!--工作地点列表--><span itemprop="worksFor">A 公司</span>和<span itemprop="worksFor">B 公司</span></p>

https 返回类似的架构://search.google.com/structured-data/testing-tool/:

@type PersonjobTitle 工作 1jobTitle 工作 2jobTitle 工作 3效劳于@type 组织名称 A 公司效劳于@type 组织名称 B 公司

假设我想要 Jobs 1 &2 成为 A 公司的一部分,而工作 3 与 B 公司合作.我将如何表达,使其在架构中具有清晰的层次结构?

我知道我可以选择 itemref(来自诸如 我如何关联 schema.org 中的项目?)但我不知道如何设计一种方法使 jobTitle 引用 Organization (worksFor).

解决方案

我认为这不会发生在 Schema 和 Google(或至少是结构化数据工具)解释它的方式之间.我可能是错的,但我认为问题在于 jobTitleworksFor 都适用于 person.因此,Google 会将这两个属性与人相关联,但不一定将这两个属性相互关联.

也可能是我在我的方法中遗漏了一些东西,而这实际上是可能的.我想发布我的答案以至少指导您或在正确方向上有更好经验的人(或证实我的怀疑).我有两种方法,我相信微数据方法在工具中出现正确但错误.我认为 JSON-LD 方法是正确的,但在结构化数据工具中没有正确显示.

微数据方法

如果您可以在一定程度上修改 DOM,您可以使用元标记在人体内嵌套一个组织.尽管结构化数据工具显示了我认为您想要的结果,但我不相信这些数据真的是相关的,因为该员工并没有真正附加到 id:

<p><!--作业列表--><span>作业 1</span>,<span>作业 2</span>,和<span>作业 3</span></p><p><!--工作地点列表--><span itemscope itemprop="worksFor" itemtype="http://schema.org/Organization"><span itemprop="name">A 公司</span><span itemscope itemprop="employee" itemref="person1" itemtype="http://schema.org/Person"><meta itemprop="jobTitle" content="工作 1"></span></span>和<span itemscope itemprop="worksFor" itemtype="http://schema.org/Organization"><span itemprop="name">B公司</span><span itemscope itemprop="employee" itemref="person1" itemtype="http://schema.org/Person"><meta itemprop="jobTitle" content="工作 2"><meta itemprop="jobTitle" content="工作 3"></span></span></p>

哪个返回:

@type = 人效劳于@type = 组织名称 = 公司 A员工@type = 人职位名称 = 职位 1效劳于@type = 组织名称 = 公司 B员工@type = 人职位名称 = 职位 2职位名称 = 职位 3

我通过嵌套 Person > Organization > Employee (Person) > JobTitle<来解决这个问题/代码>.我为带有元标记的员工添加了一个空白跨度,以便您可以保持相同的前端样式.

我担心这种方法是每个Organization 下的Employee 会与父Person 断开连接.我在父级上使用了一个 id,并在每个 Employee 中使用了 itemref 来指向该父级 id,但我不确定这是否真的受支持,或者嵌套就足够了(值得怀疑).

JSON-LD 方法

我认为 JSON-LD 方法正确地将人员与组织联系起来,但 Google 的工具最终会将 jobTitle 推送回人员,基本上给你相同的结果.不过,可能有更好的方法来关联数据.

不幸返回:

@type : http://www.example.com/Person@id:http://www.example.com/Person1姓名:约翰·史密斯职位名称:工作 1职位名称 : 工作 2职位名称 : 工作 3效劳于@type:http://www.example.com/Organization@id : http://www.example.com/CompanyA名称 : A公司效劳于@type:http://www.example.com/Organization@id : http://www.example.com/CompanyB名称 : B公司

虽然结构化数据工具以一种看起来正确的方式和一种看起来错误但看起来正确的方式提供了上述一个选项,但很难说 Google 是如何真正将数据关联起来的.也可能只是 Schema/Data 工具在更基本的层面上假设了这种关系,通常有人不会在多个组织中拥有多个职位......但我只是在推测这一点.

底线是 - 我觉得问题是 Organization 只能在 person 下列为 worksFor>.jobTitle 只能在 person 下,不能在 Organization 下.您可以将 Organization 下的 Person 关联为 employee,但这似乎只是推送 jobTitle在结构化数据工具中匿名返回给相关的person.过去,结构化数据工具已知存在一些针对 Google 文档的缺陷,因此我不确定您是否不能 100% 依赖您从中看到的内容.

Under a Person schema, I want to associate each job title with its respective organization. This is in a resume-like setting, so there are many jobs and many organizations.

Here's an actual example of some code from my project (content clipped + changed):

<div itemscope itemtype="http://schema.org/Person">
  …
  <p><!--list of jobs-->
    <span itemprop="jobTitle">Job 1</span>, 
    <span itemprop="jobTitle">Job 2</span>, and 
    <span itemprop="jobTitle">Job 3</span>
  </p>
  <p><!--list of places worked for-->
    <span itemprop="worksFor">Company A</span> and
    <span itemprop="worksFor">Company B</span>
  </p>
</div>

That returns a schema like this from https://search.google.com/structured-data/testing-tool/:

@type   Person
jobTitle    Job 1
jobTitle    Job 2
jobTitle    Job 3
worksFor    
    @type   Organization
    name    Company A
worksFor    
    @type   Organization
    name    Company B

Let's say I want Jobs 1 & 2 to be part of Company A and Job 3 to be with Company B. How would I express that so it has a clean hierarchy in the Schema?

I understand I have the option of itemref (from questions like How do I relate items in schema.org?) but I can't figure out how to engineer a way to make the jobTitle reference the Organization (worksFor).

解决方案

I don't believe this can happen between Schema and how Google (or at least the Structured Data tool) interprets it. I could be wrong, but I think the problem is that both jobTitle and worksFor apply to person. So Google will relate both of those attributes to the person but not necessarily relate the two attributes to each other.

It could also be that I'm missing something in my approach and that this is actually possible. I wanted to post my answer to at least guide you or someone with better experience in the right direction (or confirm my suspicions). I have two approaches, I believe the Microdata approach appears right in the tool but is wrong. I think the JSON-LD approach is correct but does not display properly in the Structured Data tool.

Microdata approach

If you can modify the DOM to an extent, you could use meta tags to nest an organization within the person. Although the Structured data tool shows results as I think you would want, I'm not convinced the data would really be related because the employee isn't really attached to the id:

<div itemscope itemtype="http://schema.org/Person" id="person1">
  <p><!--list of jobs-->
    <span>Job 1</span>, 
    <span>Job 2</span>, and 
    <span>Job 3</span>
  </p>
  <p><!--list of places worked for-->
    <span itemscope itemprop="worksFor" itemtype="http://schema.org/Organization">
        <span itemprop="name">Company A</span>
        <span itemscope itemprop="employee" itemref="person1" itemtype="http://schema.org/Person">
            <meta itemprop="jobTitle" content="Job 1">
        </span>
    </span> and
    <span itemscope itemprop="worksFor" itemtype="http://schema.org/Organization">
        <span itemprop="name">Company B</span>
        <span itemscope itemprop="employee" itemref="person1" itemtype="http://schema.org/Person">
            <meta itemprop="jobTitle" content="Job 2">
            <meta itemprop="jobTitle" content="Job 3">
        </span>
    </span>
  </p>
</div>

Which returns:

@type = Person

worksFor    
    @type = Organization
    name = Company A

    employee    
        @type = Person
        jobTitle = Job 1

worksFor    
    @type = Organization
    name = Company B

    employee    
        @type = Person
        jobTitle = Job 2
        jobTitle = Job 3

I approached this by nesting Person > Organization > Employee (Person) > JobTitle. I added a blank span for employee with meta tags so you can maintain the same front end styles.

My concern with this approach is that the Employee under each Organization would be disconnected from the parent Person. I used an id on the parent and used itemref in each Employee to point to that parent id but I'm not sure if that is truly supported, or maybe it being nested is enough (doubtful).

JSON-LD Approach

I think the JSON-LD approach properly relates the person to the Organization, but Google's tool in the end will push the jobTitle back to the person basically giving you the same results. There might be a better way to relate the data though.

<script type="application/ld+json">
      {
        "@context": {
            "@vocab": "http://schema.org/",
            "id": "@id",
            "graph": "@graph",
            "type": "@type"
        },
        "graph" : [
            {
                "type": "Person",
                "id": "Person1",
                "name": "John Smith",
                "worksFor" : [
                    {
                        "id": "CompanyA"
                    }, 
                    {
                        "id": "CompanyB"
                    }
                ]
            }, 
            {
                "type": "Organization",
                "id": "CompanyA",
                "name": "Company A",
                "employees": [
                    {
                        "@id" : "Person1",
                        "jobTitle" : ["Job 1", "Job 2"]
                    }
                ]
            }, 
            {
                "type": "Organization",
                "id": "CompanyB",
                "name": "Company B",
                "employees": [
                    {
                        "@id" : "Person1",
                        "jobTitle" : "Job 3"
                    }
                ]
            }
        ]
      }
</script>

Which unfortunately returns:

@type : http://www.example.com/Person
@id : http://www.example.com/Person1
name : John Smith
jobTitle : Job 1
jobTitle : Job 2
jobTitle : Job 3

worksFor    
    @type : http://www.example.com/Organization
    @id : http://www.example.com/CompanyA
    name : Company A

worksFor    
    @type : http://www.example.com/Organization
    @id : http://www.example.com/CompanyB
    name : Company B

While the Structured Data tool presents one option above in a way that looks right and one that looks wrong but seems right, it's tough to say how Google is truly relating the data. It may also just be that Schema/Data tool assumes the relation at a more basic level, where normally someone won't have multiple job titles across multiple organizations.. but I'm just speculating at that point.

Bottom line is - I feel the problem is that Organization can only be listed under a person as worksFor. jobTitle can only be under a person and not under Organization. You can relate Person under an Organization as employee, but that seems to just push jobTitle back to the related person anonymously in the structured data tool. The Structured Data Tool has known to have some flaws against Google documentation in the past, so I'm not sure you can't rely 100% on what you see from it.

这篇关于如何在 Schema.org 标记中将工作 (jobTitle) 与组织 (worksFor) 相关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆