I hope somebody can help me - i’m trying to implement some structured data in the form of a short JSON-LD script that contains tagged collection list fields. This works great where the fields have a value, but for pages that don’t the script still runs in the background with empty fields. The issue being that Google can see the incomplete schema and this can down value my site for SEO.
I’ve tried to create small addition to the script to check if the collection field is empty, and if so it should not execute the schema.
this does not work - i had it working earlier but with an error . I need a snippet of code I can use with my schema that does not throw an error.
Obv don’t know enough about JS to do it myself…Any help would be much appreciated!