对结构化数据中的@id如何工作感到困惑

时间:2019-06-12 08:31:52

标签: schema.org json-ld google-rich-snippets

基本上,我正在尝试将BlogPostingTechArticleWebPage结构化数据类型添加到我的帖子中,但是我在Google的结构化数据测试工具中遇到了错误。当我链接回到我在首页上定义的Organization结构化数据类型时,它们似乎处于中心位置,以免我不得不在多个页面中重复相同的代码。

这是结构化数据测试工具实例。谁能解释我如何正确地链接到Organizationauthorcreator属性中的publisher数据类型(位于我的主页上)?

https://search.google.com/structured-data/testing-tool#url=https%3A%2F%2Fwww.lukeharrison.dev%2Farticles%2Fmike-brewer-motors-wins-best-online-experience-at-autotraders-2018-retailer-awards%2F

我觉得可能是完全不了解@id属性以及如何正确使用它来将结构化数据链接在一起以减少重复数据的原因。

这里是涉及的代码:

  • BlogPosting
  • 链接的Organisation
  • 我收到的错误

BlogPosting

的示例
{
    "@context": "http://schema.org",
    "@type": "BlogPosting",
    "about": "Great news! Mike Brewer Motors - a project I've been heavily involved in over the past few years - has won the 'Best Online Experience' at the Autotrader 2018 Retailer Awards.",
    "articleSection": "Blog Posts",
    "author": {
        "id": "https://www.lukeharrison.dev#organization"
    },
    "copyrightHolder": {
        "id": "https://www.lukeharrison.dev#person"
    },
    "copyrightYear": "2019",
    "creator": {
        "id": "https://www.lukeharrison.dev#organization"
    },
    "dateCreated": "2018-07-20",
    "dateModified": "2018-07-20",
    "datePublished": "2018-07-20",
    "description": "Great news! Mike Brewer Motors - a project I've been heavily involved in over the past few years - has won the 'Best Online Experience' at the Autotrader 2018 Retailer Awards.",
    "genre": "Web Design & Front-End Development",
    "headline": "Mike Brewer Motors wins 'Best Online Experience' at Autotrader's 2018 Retailer Awards - Luke Harrison",
    "image": {
        "@type": "ImageObject",
        "height": 512,
        "url": "https://s.gravatar.com/avatar/c34b34964896ad0552a5b342ae08c1e2?s=512",
        "width": 512
    },
    "inLanguage": "en-GB",
    "isFamilyFriendly": "true",
    "keywords": [
        "news"
    ],
    "mainEntityOfPage": "https://www.lukeharrison.dev/articles/mike-brewer-motors-wins-best-online-experience-at-autotraders-2018-retailer-awards",
    "publisher": {
        "id": "https://www.lukeharrison.dev#organization"
    }
}

示例链接Organization,位于另一页上

{
    "@context": "http://schema.org",
    "@id": "https://www.lukeharrison.dev#organization",
    "@type": "Organization",
    "additionalType": [
        "http://www.productontology.org/id/Web_design",
        "http://www.productontology.org/doc/Search_engine_optimization",
        "http://www.productontology.org/doc/Web_development"
    ],
    "foundingDate": "2013",
    "legalName": "Luke Harrison - UX / Web Developer",
    "logo": "https://www.lukeharrison.dev/img/share-26bfb69f23.png",
    "name": "Luke Harrison - UX / Web Developer",
    "sameAs": [
        "https://twitter.com/webdevluke?lang=en-gb",
        "https://www.linkedin.com/in/lukedidit/",
        "https://github.com/WebDevLuke",
        "https://codepen.io/lukedidit/"
    ],
    "url": "https://www.lukeharrison.dev"
}

我在BlogPosting结构中收到的错误

authorcreatorpublisher

  •   

    publisher.itemtype属性的值无效。

  •   

    必须输入名称字段的值。

1 个答案:

答案 0 :(得分:1)

错误与Google的Article rich result有关(如果您不想获得如此丰富的结果,则可以忽略这些错误)。

对于AMP页面,authorpublisher是必填属性。它们需要实际的项目作为值,不支持@id引用。您仍然可以提供@id,但是您还需要指定@type和必需的属性。