Technical SEO, The Semantic Web

How To Fix the “Duplicate Key Found” Structured Data Error

There is a difference between arrays with many “key” values versus listing the same item several times outside of an array. This difference determines whether your structured data is valid or not.

For example, currently my example product has just one image:

{
"@context": "https://schema.org",
"@type": "Product",
"description":"This page is built as example for those learning to implement proper Product JSON-LD.",
"name": "Nate On A Walk Product Example",
"image": "https://nateonawalk.com/wp-content/uploads/2017/09/product-schema.jpg",
"offers": {
"@type": "Offer",
"availability": "http://schema.org/InStock",
"price": "99.99",
"priceCurrency": "USD",
"image": "https://nateonawalk.com/wp-content/uploads/2017/09/product-schema.jpg"
}
}

This is totally valid markup, and will pass the Structured Data Testing Tool without any problems. Say, though, that I wanted to include multiple images in the item. I might try something like this:

{
"@context": "https://schema.org",
"@type": "Product",
"description":"This page is built as example for those learning to implement proper Product JSON-LD.",
"name": "Nate On A Walk Product Example",
"image": "https://nateonawalk.com/wp-content/uploads/2017/09/product-schema.jpg",
"image": "https://nateonawalk.com/wp-content/uploads/2017/09/2-product-schema.jpg",
"offers": {
"@type": "Offer",
"availability": "http://schema.org/InStock",
"price": "99.99",
"priceCurrency": "USD",
"image": "https://nateonawalk.com/wp-content/uploads/2017/09/product-schema.jpg"
}
}

But if we run this through the Structured Data Testing tool, we’ll now get an error:

Duplicate key structured data error

The reason that we get this error (which is a relatively recent thing as of September 2017) is because technically the "image" items can be consolidated. Duplicate items within a JSON-LD blob goes against the idea that each item is a unique key that is matched to a unique value, even if an object can theoretically have multiples of the same type of key.

How to Fix It:

  1. Take each of your duplicate key types and reorganize them as an array. For example,

    "image": "https://nateonawalk.com/wp-content/uploads/2017/09/product-schema.jpg",
    "image": "https://nateonawalk.com/wp-content/uploads/2017/09/2-product-schema.jpg",

    becomes
    "image": ["https://nateonawalk.com/wp-content/uploads/2017/09/product-schema.jpg","https://nateonawalk.com/wp-content/uploads/2017/09/2-product-schema.jpg"],

  2. Check that your new array-heavy markup passes each item correctly:Structured data items as an array solution

And that’s it!

Posted by on .

Comments

0 comments so far.

You must log in to comment.