Fahim
Fahim

Reputation: 348

Should I include both @id and @type for node referencing in JSON-LD structured data?

While creating node referencing to avoid doing the same thing again and again, do I need to only specify the @id or both @id and @type?

For example, for a brand description, if the JSON-LD used on the homepage is:

"brand": {
      "@type": "Brand",
      "@id": "https://example.com/#brand",
      "name": "Brand Name",
      "description": "Brand description"
      "url": "https://example.com/",
      "sameAs": ["link1", "link2", "link3"]
    }

then which of the following is the right way to reference the brand on the product pages?

Option 1:

"brand": {
      "@type": "Brand",
      "@id": "https://example.com/#brand"
    }

Option 2:

"brand": {
      "@id": "https://example.com/#brand"
    }

Option 3:

"brand": "https://example.com/#brand"

Upvotes: 0

Views: 214

Answers (1)

Tony McCreath
Tony McCreath

Reputation: 3409

You only need to specify the @id, the other parameters then get merged into the one entity.

I typically add a few extra parameters if I'm referencing an entity on a different page. e.g. @type, name, url. This helps consumers know a little about the referenced entity without crawling the alternate page. And it can stop testing tools from complaining.

In your example I'd do at least option 1 and maybe also add url.

Upvotes: 1

Related Questions