2

I'm working on marking up a site with schema data using JSON-LD. After doing my homework, I learned that @id could be used to reference other snippets of schema. Such as writing WebPage schema that isPartOf my WebSite schema.

Following this, I created the basic schemas for my website; Organization, WebSite, and WebPage where WebSite links to WebPage and Organization.

When I plug my markup into Google's Structured Data Testing tool, it all gets rolled up into the WebSite schema. However, when I remove the @id references, then it is shown as three different types of schema.

With @id

Rolled up schema

Without @id

Broken up schema

Of course, I want my schema data to be interpreted as a series of relationships, that's the whole point. But I also want to make sure each individual schema is being parsed.

So what do you think, will this be okay?


Organization

{
    "@context": "http://schema.org",
    "@type": "Organization",
    "@id": "https://example.com/#organization",
    "name": "Organization",
    "legalName": "Organization, Inc",
    "description": "We rock",
    "logo": "https://www.example.com/images/logo.jpg",
    "url": "https://www.example.com",
    "telephone": "+1-111-111-1111",
    "sameAs": ["https://twitter.com/example", "https://www.linkedin.com/company/example/", "https://plus.google.com/u/0/+example", "https://www.facebook.com/example", "https://www.youtube.com/user/example", "https://www.instagram.com/example/", "https://en.wikipedia.org/wiki/example", "https://www.wikidata.org/wiki/Q1", "https://www.crunchbase.com/organization/example"],
    "address":
    {
        "@type": "PostalAddress",
        "streetAddress": "111 Street",
        "addressLocality": "Nowhere",
        "postalCode": "11111",
        "addressCountry": "United States"
    }
}

WebSite

{
    "@context": "http://schema.org",
    "@type": "WebSite",
    "@id": "https://example.com/#website",
    "name": "Website",
    "alternateName": "Web",
    "url": "https://www.example.com",
    "hasPart":
    {
        "@type": "WebPage",
        "@id": "https://www.example.com/#webpage"
    }
}

WebPage

{
    "@context": "http://schema.org",
    "@type": "WebPage",
    "@id": "https://www.example.com/#webpage",
    "name": "Webpage",
    "description": "Told you, we rock",
    "url": "https://www.example.com/",
    "isPartOf":
    {
        "@id": "https://www.example.com/#website"
    },
    "potentialAction":
    {
        "@type": "SubscribeAction",
        "agent":
        {
            "@type": "Organization",
            "@id": "https://example.com/#organization"
        },
        "object":
        {
            "@type": "Product",
            "name": "Mailing List"
        }
    }
}
Josh Bradley
  • 1,854
  • 1
  • 15
  • 31
  • Does google SDTT still merge them when you have the @id? I tried your snippet above on sdtt and it doesn't. – Ethan Jun 05 '19 at 22:00
  • Ignore my last query, it works with SDTT (was my mistake with some mods that I tried). – Ethan Jun 06 '19 at 08:02

1 Answers1

2

Of course, I want my schema data to be interpreted as a series of relationships, that's the whole point.

Exactly. Making use of @id references is one way to achieve this, nesting the full items is the other way. The result will be the same, i.e., they are equivalent.

But I also want to make sure each individual schema is being parsed.

If you know a consumer that only recognizes top-level items, you might want to adapt. It’s often possible to have one item of your choice on the top-level (by making use @reverse or inverse properties, if existing), but tools like Google’s SDTT might of course display the parsed result in a different way.

But unless you know such a consumer, I don’t think it would be advisable to omit using properties with item values. You would miss out on the most important semantic signal: relations.

In theory, providing the mainEntity/mainEntityOfPage property should be sufficient for page-oriented consumers to learn what the primary entity on that page is. In practice, consumers might not recognize/support this property, of course. But I don’t see how it should be easier for consumers to handle several top-level items, where it’s unclear in which relation they stand to each other (because the relations aren’t specified), so consumers should have an interest to support the common way how Schema.org structured data is provided on the Web.

unor
  • 92,415
  • 26
  • 211
  • 360
  • I appreciate the answer (and the edits). For clarification, by consumers I'm assuming you mean search engines? – Josh Bradley Apr 25 '18 at 02:39
  • 1
    @Blanknewkid: Consumers = anyone/anything making use of the structured data. These are primarily search engines, but there are also other services, as well as tools run by your visitors (browser add-ons, Semantic Web / Linked Data clients etc.). – unor Apr 25 '18 at 04:51
  • @unor thanks for the good fundamentals, I am learning schema. Can '@id' be used by google to reference schema on some other page on the same website, say on homepage? (As I understand, google prefers 'WebSite' on the homepage, and probably 'Organization' there too) – Ethan Jun 05 '19 at 20:54
  • @Ethan yes, exactly. – Josh Bradley Jun 05 '19 at 21:47
  • @JoshBradley Thanks, good to get the confirmation. Is it also confirmed that both 'WebSite' and 'Organization' are preferred by Google on homepage? – Ethan Jun 05 '19 at 21:52
  • @Ethan I wouldn't say preferred. But I would say it is the most appropriate use of schema based on current documentation. Schema is very flexible. – Josh Bradley Jun 05 '19 at 21:54
  • @JoshBradley Thanks Josh. Yes, agree that schema is very flexible, but Google doesn't seem to support many features of it at the moment. Like, I came across this [link](https://webmasters.stackexchange.com/questions/121804/) where google is just parsing but not 'digesting' the schema, to show the warnings – Ethan Jun 05 '19 at 21:59
  • 3
    @Ethan: As far as I know, Google doesn’t document if they follow `@id` URIs. Also note that these URIs don’t necessarily have to be resolvable -- it’s a good practice to provide a document behind this URI, but that’s not required. – unor Jun 06 '19 at 14:14