# If statement for missing variable content

**URL:** <https://community.hubspot.com/t/if-statement-for-missing-variable-content/22460>\
**Category:** CMS Development\
**Tags:** design-manager\
**Created:** [July 3, 2020, 6:36pm UTC](https://community.hubspot.com/t/if-statement-for-missing-variable-content/22460 "2020-07-03T18:36:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MN1](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mn1/32/99730_2.png) [@MN1](https://community.hubspot.com/u/MN1)\
**Post date:** [July 3, 2020, 6:36pm UTC](https://community.hubspot.com/t/if-statement-for-missing-variable-content/22460/1 "2020-07-03T18:36:54Z")

</div>

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?

this is the pertinent section of the code:

“image”: {  
“@type”: “ImageObject”,  
“url”: “{{ content.featured\_image }}”  
},

Where I want to do something like if content.featured\_image is not found use site\_settings.logo\_src or some absolute URL.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Jake\_Lett](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jake_lett/32/45178_2.png) [@Jake\_Lett](https://community.hubspot.com/u/Jake_Lett)\
**Post date:** [July 5, 2020, 7:34am UTC](https://community.hubspot.com/t/if-statement-for-missing-variable-content/22460/2 "2020-07-05T07:34:57Z")

</div>

I found this code snippet provided by Stephanie that should achieve the result you are looking for [Set a default featured image on your HubSpot site](https://www.stephanieogaygarcia.com/hubspot-website-development/set-a-default-featured-image-on-your-hubspot-site)

**Add to the HEAD of your template**

```auto
{% if !content.featured_image %}
<meta property="og:image" content="https://www.yourdomain.com/hubfs/yourimage.jpg" />
{% endif %}

```

* * *

**Jacob Lett**

[Freelance HubSpot CMS Developer & Web Designer](https://bootstrapcreative.com/hubspot-designer/?utm_source=HubSpotCommunity&utm_term=tagline)

* * *

[  
  ![28844i368E9AAC739341A8.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/0/0fa6bcd420e080a29fc75d42359cf2879b6e162d.png)  
 ](https://bootstrapcreative.com/hubspot-designer/?utm_source=HubSpotCommunity&utm_term=logo)

Located in Michigan, USA

[**Get a free estimate now ›**](https://bootstrapcreative.com/contact-us/?utm_source=HubSpotCommunity&utm_term=free%20estimate)

* * *

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [July 6, 2020, 10:59am UTC](https://community.hubspot.com/t/if-statement-for-missing-variable-content/22460/3 "2020-07-06T10:59:08Z")

</div>

Hi @MN1,

[@Jake\_Lett](https://community.hubspot.com/t5/user/viewprofilepage/user-id/72866) is right. For your specific code it would be:

```auto
"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.

---

<div class="post-metadata">

**Author:** ![MN1](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mn1/32/99730_2.png) [@MN1](https://community.hubspot.com/u/MN1)\
**Post date:** [July 6, 2020, 12:18pm UTC](https://community.hubspot.com/t/if-statement-for-missing-variable-content/22460/4 "2020-07-06T12:18:36Z")

</div>

Bingo, thank you both! Was obviously way overthinking this. Much appreciated.
