Duplicate or link to WebSite JSON-LD?

后端 未结 1 583
深忆病人
深忆病人 2021-01-24 03:36

I\'m replacing the microdata (itemscope et al) on our sites with JSON-LD. Do I need to declare the WebSite on every page, or can I place it once on the

相关标签:
1条回答
  • 2021-01-24 04:08

    Do I need to declare the WebSite on every page, or can I place it once on the home page?

    From the perspectives of Schema.org and Linked Data, it’s perfectly fine (and I would say it’s even the best practice) to provide an item only once, and reference it via its URI whenever it’s needed.

    In JSON-LD, this can be done with @id. For example:

    <!-- on the homepage -->
    <script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "WebSite",
      "@id": "http://example.com/#site",
      "hasPart": {
        "@type": "WebPage",
        "@id": "http://example.com/"
      }
    }
    </script>
    
    <!-- on another page -->
    <script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "WebPage",
      "@id": "http://example.com/foobar",
      "isPartOf": {"@id": "http://example.com/#site"}
    }
    </script>
    

    Whether Google actually follows these references is not clear (as far as I know, it’s undocumented)¹. It’s clear that their testing tool doesn’t show the data from referenced URIs, but that doesn’t have to mean much. At least their testing tool displays the URI (as "ID") in case one is provided.

    If you want to provide a URL value for the video property, note that URL is not one of its expected values. While Schema.org still allows this (any property can have a text or URL value), it’s likely that some consumers will handle only expected values. It’s also perfectly fine to provide a VideoObject value if you only provide a url property. The fact that Google’s testing tool gives errors doesn’t mean that something’s wrong; it just means that Google won’t consider this video for their video-related rich results.


    ¹ But for the few rich result features Google offers, authors would typically not need to reference something from another page anyway, I guess. Referencing of URIs is typically done for other Semantic Web and Linked Data cases.

    0 讨论(0)
提交回复
热议问题