Prowadzimy rekrutację w Polsce do naszych biur w Krakowie i Tarnowie - dowiedz się więcej!

Shopify Liquid hints we use in our day-to-day work

How to override default theme.liquid file

{% layout 'alternative' %}

In this instance, the default theme.liquid will be not be applied but rather the layout called alternative.liquid.

Output data without any layout being applied

When it's useful? For example you want to master some sort of internal pseudo-API that supposed to fetch data using Liquid (Shopify is having different limits promoting the Liquid for data fetching) and you want to output this gathered by Liquid data in a form of JSON to later consume somewhere else.

It's possible to request that the layout file isn't applied. The syntax to request that a layout file isn't applied is:

{% layout none %}

This needs to be the first line at the top of the relevant template (index.liquid, product.liquid, etc.). This way if you formatted output in Liquid as a JSON you will get a nice JSON.

Advanced submenus for collections, tied up links from navigation to specific collection handle

{{ collection.title }} 
{% assign collection_handle = "collection-" | append: collection.handle %} 
<ul> 
  {% for link in linklists[collection_handle].links %} 
    {% assign sub_collection = link.object %} 
    <li><a href="{{ link.url }}">{{ link.title }}</a></li>
  {% endfor %}
</ul>

Detect using Liquid on which page or a Template you are

Useful when you want to display specific elements or UX on specific page or a template

For example If you want some code to be rendered on the homepage, you could use

<textarea> {% if template.name == "index" %} do something {% endif %} </textarea>

or if you want to check which template is being used, use this code below

<textarea> {% if template contains 'page. templatename' %} do something {% endif %} </textarea>

There is way how to request some more information using Shopify docs

https://shopify.dev/docs/api/liquid/objects/request

screenshot of the request liquid property from Shopify Documentation

Also some gems from this discussion about Liquid on Shopify Github

https://github.com/Shopify/liquid/issues/525

and

<textarea> Hi I was able to get this by </textarea>

by: https://github.com/srinathperera101

/

Visit Our Office

16 Halcyon Ln
Aliso Viejo, CA 92656

Let's Talk

Phone: (415) 910-2498

call us
CUSTOMER SERVICE

We are happy to listen
suggest a feature, report a bug.

Submit Feature Request