Shopify showing liquid template error of “include usage is not allowed in this context”

 

What is this issue?

This is liquid template including issue. This appears where you have included liquid template with syntax something like this `{% include ‘your-liquid-template-name’ %}`. But the include syntax is correct. This is the way we include another snippet or template inside another liquid template.

 

Why this appeared?

As per my experience, this started appear on new Debut theme version 14.1.0. According to the syntax written in this version of theme the liqiud template including syntax is different. It is now `{% render ‘your-liquid-template-name’ %}`

 

What is the solution?

The solution is to use `render` term instead of `include` while including another liquid template.

 

What is the difference between `include` and `render`?

With include even without passing parameters/values to another liquid template all the variables are available but with render it’s not same. With render syntax you need to pass parameters else the variables on parent liquid template(the template where another liquid template is being included) won’t be available.

For eg. If you are including liquid snippet from `product-template.liquid`

With include you do {% include ‘product-card-grid’ %}
All the variables on product-template.liquid will be available on `product-card-grid`

With render you do {% render ‘product-card-grid’, max_height: max_height, product: product, show_vendor: section.settings.show_vendor %} i.e. only these passed variables will be allowed to be used on product-card-grid template.

Please let me know in comments below if you found other differences and scenarios you discovered in.

Thank you.

Suman K.C

eCommerce Developer, writes about stuff related to eCommerce development. Currently based in Kathmandu, loves reading about startups & new technology, introvert nature, fond of traveling & playing futsal.

More Posts