nirvana-msu
nirvana-msu

Reputation: 4077

Google Structured Data Testing Tool fails to validate type as an alias of @type in JSON-LD with schema.org context

If you use e.g. lanthaler/JsonLD to compact JSON-LD data with schema.org context, you will notice that @type keyword is replaced with an alias type in the output, which makes sense given that

Schema.org recently added a keyword alias from @type to just type

The problem is that Google's Structured Data Testing Tool fails to recognize this alias. Here's a simple example to demonstrate this (try replacing type with @type, and it will pass validation)

{
    "@context": "http://schema.org",
    "type": "Product",
    "name": "SomeName"
}

Which raises a few questions:

  1. Does the fact that testing tool cannot validate this valid markup mean google will ignore it, and it will not affect display in search results?
  2. If so, is there a way to force lanthaler/JsonLD to avoid replacing @type with type during compaction (ideally without any other side-effects)?

Upvotes: 1

Views: 658

Answers (1)

Markus Lanthaler
Markus Lanthaler

Reputation: 3823

To answer your second question: yes, by using a different context. For instance the following:

{
  "@context": {
    "@vocab": "http://schema.org/"
  }
}

This context ends up in the result but that is fine as the SDTT is able to process this.

Upvotes: 1

Related Questions