JSON-LD Alt Property Not Recognized #1
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
If the image alt property front matter is set it creates an invalid JSON-LD (schema). When using the Schema Markup Validator the following error message is returned, "The property alt is not recognized by the schema (e.g. schema.org) for an object of type ImageObject".
Examining the Schema specification it confirms that an ImageObject does not have a property called "alt". As I understand it the property that should be used in this context would be
description
.According to the Jekyll SEO Tag Documentation the
alt
tag is used for the alternative image text in Open Graph (og:image:alt
) and X (Twitter) (twitter:image:alt
). There is no mention of JSON-LD use.Example Front Matter
Example JSON-LD Output
As far as I can tell this issue has been around since Jekyll SEO Tag v2.8.0. There was mention of this problem in issue JSON-LD errors - Issue #190 . However, I was unable to find any further mention of this problem nor a resolution.
I'm not a Ruby programmer, but I believe the following will resolve the problem by editing the image method within the file json_ld_drop.rb for Jekyll SEO Tag v2.8.0.
The basic logic is this...
image.alt
exists andimage.description
does not exist then createimage.description
with the same value ofimage.alt
Else ifimage.alt
does not exist andimage.description
does not then createimage.alt
with the same value ofimage.description
image.alt
exists delete itThis solution would allow the alt property to be set for Open Graph (
og:image:alt
) and X (Twitter) (twitter:image:alt
), but at the same time automatically creating which ever is missing thealt
ordescription
for use in JSON-LD.Code Changes
Before
After