Hi, I'm trying to configure some dynamic schema for a section of our site. The schema type I am using requires an img URL to be set. This is fine and straightforward when the page has a featured image, but when it doesn't the markup returns an error for the missing image.
I have pretty much 0 experience with hubl and just sort of learning as I go, so my question: Is it possible to create some kind of conditional variable/if statement to substitute the featured image variable if it's not present?
@Jake_Lett is right. For your specific code it would be:
"image": {
"@type": "ImageObject",
"url": "{% if content.featured_image %}{{ content.featured_image }}{% else %}[YOUR LOGO URL]{% endif %}"
},
You might need to make {{ content.featured_image }} into {{ content.featured_image.url }} as an image in HubL has a few properties e.g. height, width, alt, and url.
@Jake_Lett is right. For your specific code it would be:
"image": {
"@type": "ImageObject",
"url": "{% if content.featured_image %}{{ content.featured_image }}{% else %}[YOUR LOGO URL]{% endif %}"
},
You might need to make {{ content.featured_image }} into {{ content.featured_image.url }} as an image in HubL has a few properties e.g. height, width, alt, and url.