Is there a way using liquid to know if its published or not?

Highlighted
New Member
5 0 0

Hi,

I would like to be able to define variable values depending on whether or not the theme is published or unpublished. 

For example:

if theme is live

    isLive = true

else

   isLive = false

 

and then define different values to the same variables depending on that state.

Is this possible?

0 Likes
Highlighted
Shopify Partner
67 15 16

You can use theme liquid object and match its id with the id of the published theme (https://shopify.dev/docs/themes/liquid/reference/objects/theme)

{% if theme.id == 123456789 %}
   {% assign isLive = true %}
{% else %}
   {% assign isLive = false %}
{% endif %}