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?
I followed the documentation Advanced Usage - Customizing Image Ouput to set the image path and image alt properties. When attempting to validate the generated JSON-LD I received the following error message, "The property alt is not recognized by the schema (e.g. schema.org) for an object of type ImageObject."
This problem was brought up in JSON-LD errors · Issue #190 · jekyll/jekyll-seo-tag. However it appears that the alt property portion of the issue was never addressed.
Environment
Problem
The property alt is not recognized by the schema (e.g. schema.org) for an object of type ImageObject. This occurs when
using the Jekyll plugin Jekyll SEO Tag and having the front matter set with an image path and alt values as illustrated
below.
With these values set, it generates the following JSON-LD that contains an invalid alt property. To confirm this is
indeed invalid, use the Schema Markup Validator with the following example and refer to ImageObject - Schema.org Type.
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
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
Pull request was issued at GitHub in hopes it will be merged into the Jekyll SEO Tag plugin.
The fix-json-ld-alt branch contains the code changes to fix the problem. Though this issue has not been officially accepted I will be considering this issue resolved and therefore closing it.