Liquid


Logic

{% comment %}
Comments will be hidden
My name is {% comment %}Mark{% endcomment %} Dunkley My name is Dunkley
{% raw %}
No liquid will be parsed in within these tags
{% raw %} {{mustache.js}} {% endraw %}
{% if %}
"If" statements let you determine if something is true or not
if username is elvis {% if user.name == 'elvis' %}
hey Elvis
{% endif %}
hey Elvis Else if example {% if user.name == 'elvis' %}
hey elvis
{% elsif user.name == 'Mark' %}
hey mark
{% else %}
hi stranger
{% endif %}
hey ugly
{% unless %}
If not true, then it will do something
username is not "elvis" {% unless user.name == 'elvis' %}
hey ugly
{% endunless %}
hey ugly
{% case %}
Used when you have consistent cases of something
case [handle is 'cookie'] {% case handle %}
{% when 'cake' %}
This is a cake
{% when 'cookie' %}
This is a cookie
{% else %}
This is not a cookie/cake
{% endcase %}
This is a cookie
{% cycle %}
Use when you need to alternate between something.
Basic example {% cycle 'one', 'two' %}
{% cycle 'one', 'two' %}
{% cycle 'one', 'two' %}
one
two
one
Group cycles {% cycle 'group 1': 'one', 'two', 'three' %}
{% cycle 'group 1': 'one', 'two', 'three' %}
{% cycle 'group 2': 'one', 'two', 'three' %}
{% cycle 'group 2': 'one', 'two', 'three' %}

one two one two
{% for %}
Use "for loops" if you want to repeat/test something over and over
Loop options
  • limit:
  • offset:
For Loop [product are: hat, pez, pad] {% for product in collection.products %}
{{ product.name }},
{% endfor %}
hat, pez, pad, Limit [product are: hat, pez, pad] {% for product in collection.products limit:2 %}
{{ product.name }},
{% endfor %}
hat, pez,
{% tablerow %}
Generate table rows/cells
You have a few options
  • cols:
  • limit:
Example [products are: hat, pez, pad] <table>
{{% tablerow product in collection.products cols: 2 %}
<td>
{{ product.title }}
</td>
{% endtablerow %}
</table>
<table>
<tr>
<td>hat</td>
<td>pez</td>
</tr>
<tr>
<td>pad</td>
</tr>
</table>
{% assign %}
Create variables
{% assign myvariable = false %}
{% if myvariable != true %}
The if statement is valid
{% endif %}
The if statement is valid
{% capture %}
Similar to {% assign %} and allows you to "capture" a variable you output
{% capture productlink %}
{% product.url %}
{% endcapture %}

{% productlink %}
/products/apple
{% include %}
Insert a snippet into your layout
Within the snippet color.liquid color: '{{ color }}'
shape: '{{ shape }}'

Within the template index.liquid {% assign shape = 'circle' %}
{% include 'color' %}
{% include 'color' with 'red' %}
{% include 'color' with 'blue' %}
{% assign shape = 'square' %}
{% include 'color' with 'red' %}
color: ''
shape: 'circle'
color: 'red'
shape: 'circle'
color: 'blue'
shape: 'circle'

color: 'red'
shape: 'square'
{% increment variable %}
Creates a new number variable, and increases its value by one every time it is called. The initial value is 0. note: Variables created through the increment tag are independent from variables created through assign or capture.
{% increment variable %}
{% increment variable %}
{% increment variable %}

0
1
2
{% decrement%}
Creates a new number variable, and decreases its value by one every time it is called. The initial value is -1. Variables declared inside decrement are independent from variables created through assign or capture.
{% decrement variable %}
{% decrement variable %}
{% decrement variable %}

-1
-2
-3
{% form%}
Creates an HTML form element with all the necessary attributes (action, id, etc.) and input to submit the form successfully.
parameters
activate_customer_password
Generates a form for activating a customer account on the activate_account.liquid template. {% form 'activate_customer_password' %}
...
{% endform %}

>form accept-charset="UTF-8" action="https://my-shop.myHaravan.com/account/activate" method="post"> >input name="form_type" type="hidden" value="activate_customer_password" /> >input name="utf8" type="hidden" value="✓" /> ... new_comment
Generates a form for creating a new comment in the article.liquid template. Requires the article object as a parameter. {% form "new_comment", article %}
...
{% endform %}

>form< accept-charset="UTF-8" action="/blogs/news/10582441-my-article/comments" class="comment-form" id="article-10582441-comment-form" method="post"> ... >/form> contact Generates a form for submitting an email through the Liquid contact form. {% form 'contact' %} ... {% endform %}
<input name="form_type" type="hidden" value="contact" /> <input name="utf8" type="hidden" value="✓" /> ...
create_customer Generates a form for creating a new customer account on the register.liquid template. {% form 'create_customer' %} ... {% endform %} <form accept-charset="UTF-8" action="https://my-shop.myHaravan.com/account" id="create_customer" method="post"> <input name="form_type" type="hidden" value="create_customer" /> <input name="utf8" type="hidden" value="✓" /> ... </form> customer_address Generates a form for creating or editing customer account addresses on the addresses.liquid template. When creating a new address, include the parameter customer.new_address. When editing an existing address, include the parameter address. {% form 'customer_address', customer.new_address %} ... {% endform %} <form accept-charset="UTF-8" action="/account/addresses/70359392" id="address_form_70359392" method="post"> <input name="form_type" type="hidden" value="customer_address" /> <input name="utf8" type="hidden" value="✓" /> ... </form> customer_login Generates a form for logging into Customer Accounts on the login.liquid template. {% form 'customer_login' %} ... {% endform %} <form accept-charset="UTF-8" action="https://my-shop.myHaravan.com/account/login" id="customer_login" method="post"> <input name="form_type" type="hidden" value="customer_login" /> <input name="utf8" type="hidden" value="✓" /> ... </form> recover_customer_password Generates a form for recovering a lost password on the login.liquid template. {% form 'recover_customer_password' %} ... {% endform %} <form accept-charset="UTF-8" action="/account/recover" method="post"> <input name="form_type" type="hidden" value="recover_customer_password" /> <input name="utf8" type="hidden" value="✓" /> ... </form>
{% layout %}
Loads an alternate template file from the layout folder of a theme. If no alternate layout is defined, the theme.liquid template is loaded by default.
{% layout 'alternate' %} If you don't want any layout to be used on a specific template, you can use none. {% layout none %}
{% paginate %}
Splitting products, blog articles, and search results across multiple pages is a necessary component of theme design as you are limited to 50 results per page in any for loop. The paginate tag works in conjunction with the for tag to split content into numerous pages. It must wrap a for tag block that loops through an array, as shown in the example below:
{% paginate collection.products by 5 %} {% for product in collection.products %} {% endfor %} {% endpaginate %} The by parameter is followed by an integer between 1 and 50 that tells the paginate tag how many results it should output per page. Within paginate tags, you can access attributes of the paginate object. This includes the attributes to output the links required to navigate within the generated pages.

Operators

== !- > < >= <= or and contains
You can use operators in all the above logic statements
  • == equal
  • != not equal
  • > bigger than
  • < less than
  • >= bigger or equal
  • <= less or equal
  • or this or that
  • and must be this and that
  • contains includes the substring if used on a string, or element if used on an array

Images


sizes

  • 16x16 pico
  • 32x32 icon
  • 50x50 thumb
  • 100x100 small
  • 160x160 compact
  • 240x240 medium
  • 480x480 large
  • 600x600 grande
  • 1024x1024 1024x1024
  • 2048x2048 2048x2048
  • master largest image (2048x)

Misc


2 types of liquid tags
We use liquid to generate our code. There are 2 types
Will output something {{ 'output me' }} output me Logic statement {% logic %}
page_description
Depending on which template Haravan is rendering it will pull a Google friendly description of the page. Use it for meta descriptions.
{{ page_description }}
page_title
Renders the template's default page title text selected by Haravan
{{ page_title }}
if variable is blank/empty/null
Instead of doing == "", or == empty you can take advantage of "nil" by simply writing {% if variableName %}. If there is nothing the variable will return false
{% if fulfillment.tracking_number %} We have a tracking number! {% endif %}
Search only products
Only returns products in the search results
<input type="hidden" name="type" value="product" />
layout
By default "layout.liquid" is applied to all themes, but you can specify a new layout by creating a new layout and use the tag {% layout "layout2" %} or if you don't want a layout use {% layout "none" %} .
{% layout "layout2" %}
current_tags
Renders a list of all the tags, only works on collection.liquid and blog.liquid.
What is a handle?
A handle is how we name our elements (collections, products, blogs, etc)

Theme Settings


Text field
            <tr> <th><label for="my_text">Name of this setting.</label></th> <td><input type="text" id="my_text" name="my_text" class="text" value=""/></td> </tr>
          
Multiline text field
            <tr> <th><label for="my_textarea">Name of this setting.</label></th> <td><textarea rows="4" cols="20" id="my_textarea" name="my_textarea" class="textarea" value=""/></td> </tr>
          
Select menus
            <tr> <th><label for="my_dropdown">Name of this Setting</label></th> <td> <select name="my_dropdown" id="my_dropdown"> <option value="1" selected="selected">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </td> </tr>
          
Checkboxes
            <tr> <th><label for="my_checkbox">Name of this Setting</label></th> <td><input type="checkbox" id="my_checkbox" name="my_checkbox" value="1" /></td> </tr>
          
File Uploads
            <tr> <th><label for="my_img">Settings Name</label></th> <td> <input type="file" id="my_img" name="my_img.jpg" data-max-width="100" data-max-height="200" /> </td> </tr>
          
CSS/Specialty Classes
            <input class="color" name="background_color" value="#332211" /> <select class="collection" name="frontpage_collection" /> <select class="font" name="header_font" id="header_font"> <option value="Georgia, Utopia, 'Times New Roman', Times, serif" selected="selected">Georgia</option> </select> <select class="blog" name="main_blog" /> <select class="page" name="welcome_message" /> <select class="linklist" name="sidebar_linklist" /> <select class="snippet" name="sidebar_widget" />
          
Haravan credit
Necessary for any themes on the theme store
            {{ powered_by_link }}
          

Loop Helpers


forloop.length
length of the entire for loop
forloop.index
index of the current iteration
forloop.index0
index of the current iteration
forloop.rindex
how many items are still left?
forloop.rindex0
how many items are still left?
forloop.first
is this the first iteration?
forloop.last
is this the last iteration?

Pagination


paginate.page_size
The size of each page. That's the amount of items displayed.
paginate.current_page
On which page are we right now? You can also use {{ current_page }} as well.
paginate.current_offset
How many items did we skip over so far
paginate.pages
The amount of pages there are
paginate.items
Total amount of items in this collection
paginate.previous
Exists if there is a previous page.
paginate.previous.title
Title of the link
paginate.previous.url
URL of the link
paginate.next
paginate.next.title
paginate.next.url
URL of the link
paginate.parts
Array of all the parts which make up a good navigation for this pagination. Each element will have any of these three elements: part.is_link (Is this part a link?), part.title (Link Title), part.url (Link URL)
part.is_link

Liquid Filters


map
Accepts an array element's attribute as a parameter and creates a string out of each array element's value.
{% assign collection_titles = collections | map: 'title' %} {{ collection_titles }} SpringSummerFallWinter
size
Returns the size of a string or an array.
{{ 'is this a 30 character string?' | size }} 30 size can be used in dot notation, in cases where it needs to be used inside a tag. {% if collections.frontpage.products.size > 10 %} There are more than 10 products in this collection! {% endif %}
script_tag
Generates a script tag.
{{ 'shop.js' | asset_url | script_tag }} <script src="//cdn.Haravan.com/s/files/1/0087/0462/t/394/assets/shop.js?28178" type="text/javascript"> </script>
ceil
Rounds an output up to the nearest integer.
{{ 4.6 | ceil }}
{{ 4.3 | ceil }}
5
5
divided_by
Divides an output by a number.
<!-- product.price = 200 -->
{{ product.price | divided_by: 10 }}
20
floor
Rounds an output down to the nearest integer.
{{ 4.6 | floor }}
{{ 4.3 | floor }}
4
4
round
Rounds the output to the nearest integer or specified number of decimals.
{{ 4.6 | round }} 5
times
Multiplies an output by a number.
<!-- product.price = 200 -->
{{ product.price | times: 1.15 }}
230
modulo
Divides an output by a number and returns the remainder.
{{ 12 | modulo:5 }} 2
camelcase
Converts a string into CamelCase.
{{ 'coming-soon' | camelcase }} ComingSoon
md5
Converts a string into an MD5 hash. An example use case for this filter is showing the Gravatar image associated with the poster of a blog comment:
<img src="http://www.gravatar.com/avatar/{{ comment.email | remove: ' ' | strip_newlines | downcase | md5 }}" /> <img src="http://www.gravatar.com/avatar/2a95ab7c950db9693c2ceb767784c201" />
slice
The slice filter returns a substring, starting at the specified index. An optional second parameter can be passed to specify the length of the substring. If no second parameter is given, a substring of one character will be returned.
{{ "hello" | slice: 0 }}
{{ "hello" | slice: 1 }}
{{ "hello" | slice: 1, 3 }}

h
e
ell

If the passed index is negative, it is counted from the end of the string. {{ "hello" | slice: -3, 2 }} {{ "hello" | slice: -3, 2 }}
split
The split filter takes on a substring as a parameter. The substring is used as a delimiter to divide a string into an array.
{% assign words = "Uses cheat codes, calls the game boring." | split: ' ' %}
First word: {{ words.first }}
First word: {{ words[0] }}
Second word: {{ words[1] }}
Last word: {{ words.last }}
All words: {{ words | join: ', ' }}
{% for word in words %}
{{ word }}
{% endfor %}

First word: Uses
First word: Uses
Second word: cheat
Last word: boring.
All words: Uses, cheat, codes,, calls, the, game, boring.
Uses cheat codes, calls the game boring.
lstrip
Strips tabs, spaces, and newlines (all whitespace) from the left side of a string..
"{{ ' too many spaces ' | lstrip }}" <!-- Notice the empty spaces to the right of the string -->
too many spaces
rstrip
Strips tabs, spaces, and newlines (all whitespace) from the right side of a string.
{{ ' too many spaces ' | strip }} too many spaces
uniq
Removes any duplicate instances of an element in an array.
{% assign fruits = "orange apple banana apple orange" %} {{ fruits | split: ' ' | uniq | join: ' ' }} orange apple banana
url_escape
Identifies all characters in a string that are not allowed in URLS, and replaces the characters with their escaped variants.
{{ " & " | url_escape }} %3Chello%3E%20&%20%3CHaravan%3E
url_param_escape
Replaces all characters in a string that are not allowed in URLs with their escaped variants, including the ampersand (&).
{{ " & " | url_param_escape }} %3Chello%3E%20%26%20%3CHaravan%3E
file_url
Returns the URL of a file in the Files page of the admin.
{{ 'size-chart.pdf' | file_url }} //cdn.Haravan.com/s/files/1/0087/0462/files/size-chart.pdf?28261
customer_login_link
Generates a link to the customer log in page.
{{ 'Log in' | customer_login_link }} <a href="/account/login" id="customer_login_link">Log in
payment_type_img_url
Returns the URL of the payment type's SVG image. Used in conjunction with the shop.enabled_payment_types variable.
{% for type in shop.enabled_payment_types %} <img src="{{ type | payment_type_img_url }}" /> {% endfor %} <!-- If shop accepts American Express, MasterCard and Visa --> <img src="//cdn.Haravan.com/s/global/payment_types/creditcards_american_express.svg?3cdcd185ab8e442b12edc11c2cd13655f56b0bb1">
Haravan_asset_url
Returns the URL of a global assets that are found on Haravan's servers. Globally-hosted assets include:
option_selection.js
api.jquery.js
Haravan_common.js,
customer_area.js
currencies.js
customer.css
{{ 'option_selection.js' | Haravan_asset_url | script_tag }} <script src="//cdn.Haravan.com/s/Haravan/option_selection.js?20cf2ffc74856c1f49a46f6e0abc4acf6ae5bb34" type="text/javascript"></script>
default_errors
Outputs default error messages for the form.errors variable. The messages returned are dependent on the strings returned by form.errors.
{% if form.errors %} {{ form.errors | default_errors }} {% endif %} <!-- if form.errors returned "email" --> Please enter a valid email address.
json
Converts a string into JSON format.
var content = {{ pages.page-handle.content | json }}; The json filter can also used to make Liquid objects readable by JavaScript: var json_product = {{ collections.featured.products.first | json }};
var json_cart = {{ cart | json }};
escape(input)
Use this filter to escape a string.
{{ link.title | escape }}
append(input)
Use this filter to append characters to a string.
{{ 'sales' | append: '.jpg' }} sales.jpg
prepend(input)
Use this filter to prepend characters to a string.
size(input)
Return the size of an array or string
{{ 'this is an 30 character string' | size }} 30
join(input, segmenter = ' ')
"joins" an array with the specified character. Example:
{{ product.tags | join: ', ' }} tag1, tag2, tag3
downcase(input)
convert a input string to 'downcase'
upcase(input)
convert a input string to UPCASE
strip_html
This will strip all html tags from the text passed to the block. Useful in combination with truncate. {{ article.content | strip_html | truncate: 20 }}
strip_newlines
Removes all newlines from the input
truncate(input, characters = 100)
Truncate a string down to x characters. Take care with truncating text which has html elements in it. In these cases you probably want to run the string through the strip_html filter first (see below).
truncatewords(input, words = 15)
Truncate string down to x words
date(input, format)
Reformat a date
  • %a - The abbreviated weekday name (``Sun'')
  • %A - The full weekday name (``Sunday'')
  • %b - The abbreviated month name (``Jan'')
  • %B - The full month name (``January'')
  • %c - The preferred local date and time representation
  • %d - Day of the month (01..31)
  • %H - Hour of the day,24-hour clock (00..23)
  • %I - Hour of the day,12-hour clock (01..12)
  • %j - Day of the year (001..366)
  • %m - Month of the year (01..12)
  • %M - Minute of the hour (00..59)
  • %p - Meridian indicator (``AM'' or ``PM'')
  • %S - Second of the minute (00..60)
  • %U - Week number of the current year, starting with the first Sunday as the first day of the first week (00..53)
  • %W - Week number of the current year, starting with the first Monday as the first day of the first week (00..53)
  • %w - Day of the week (Sunday is 0,0..6)
  • %x - Preferred representation for the date alone,no time
  • %X - Preferred representation for the time alone,no date
  • %y - Year without a century (00..99)
  • %Y - Year with century
  • %Z - Time zone name
  • %% - Literal ``%'' character
first(array)
Get the first element of the passed in array
{{ product.images | first | to_img }}
last(array)
Get the last element of the passed in array
{{ product.images | last | to_img }}
newline_to_br
Inserts a <br /> linebreak tag in front of every \n linebreak character.
replace(input, substring, replacement)
Will replace all occurrences of a string with another.
{{ product.description | replace: 'super', 'mega' }}
replace_first(input, substring, replacement)
Will replace the first occurrence of a string with another.
{{ product.description | replace_first: 'super', 'mega' }}
remove(input, substring)
Removes all occurrences of the substring from the input.
{{ product.description | remove: 'way too expensive'}}
remove_first(input, substring)
Removes only the first occurrence of the substring from the input.
{{ product.description | remove_first: 'remove-me'}}
plus(input, operand)
Gets the result of adding input to operand. When strings are passed, it parses strings as integers before adding.
Showing {{ paginate.current_offset }}-{{ paginate.current_offset | plus: paginate.page_size }} items
minus(input, operand)
Gets the result of subtracting input from operand. When strings are passed, it parses strings as integers before adding.
{{ product.price | minus: 10 | money_with_currency }}

Filters


asset_url
Gives you the url for an asset
{{ 'shop.css' | asset_url }}
camelize
Converts the text into CamelCase
{{ 'camel case' | camelize }} CamelCase
capitalize
Capitalizes the first word
{{ 'capitalize me' | capitalize }} Capitalize me
default_pagination
used in conjunction with the {{ paginate }} liquid tag
global_asset_url
Returns the url for a global asset (global assets are faster than regular asset_url)
{{ 'image.png' | global_asset_url }}
handleize
Strips and converts special characters (%@*$...etc) out of the string, so you can use the text in a url
{{ '100% M&Ms!!!' | handleize }} 100-m-ms
img_tag
Generates an img tag
Basic usage {{ 'image-name.gif' | asset_url | img_tag }} <img src="http://static.Haravan.com/s/files/1/0036/9672/assets/image-name.gif?1255697690" alt="" /> To add alt text: {{ 'image-name.gif' | asset_url | img_tag:'whatever alt text' }}
link_to
Generates a html link
Simple {{ 'Click' | link_to: 'http://markdunkley.com' }} <a href="http://markdunkley.com" >Click</a> Add a title {{ 'Click' | link_to: 'http://markdunkley.com','Title text' }} <a href="http://markdunkley.com" title="Title text">Click</a>
link_to_vendor
Generates a html link to the vendor of the product
{{ "Pepsi" | link_to_vendor }} <a title="Pepsi" href="/collections/vendors?q=Pepsi">Pepsi</a>
link_to_type
Generates a html link to the type of the product
{{ "Cola" | link_to_type }} <a title="Cola" href="/collections/vendors?q=Cola">Cola</a>
link_to_tag*
This filter creates a link to all products in a collection that have the given tag.
{% for tag in collection.tags %}
{{ tag | link_to_tag: tag }}
{% endfor %}
link_to_add_tag*
This filter creates a link to all products in a collection that have the given tag and all the previous tags that might have been added already.
{% for tag in collection.tags %}
{{ '+' | link_to_add_tag: tag }} {{ tag }}
{% endfor %}
link_to_remove_tag*
This filter creates a link to all products in a collection that have the given tag and all the previous tags that might have been added already.
{% for tag in collection.tags %}
{{ '+' | link_to_add_tag: tag }} {{ tag }}
{% endfor %}
highlight_active_tag*
This filter creates a span with the class active around the tag if it is active
{% for tag in collection.tags %}
{{ tag | highlight_active_tag | link_to_tag: tag }}
{% endfor %}
money_with_currency
Wraps with the currency symbol and abbreviation
{{ product.price | money_with_currency }} $19.00 CAD
money_without_currency
Formats the price using a decimal
{{ product.price | money_without_currency }} 19.00
money
Adds the currency symbol
{{ product.price | money }} $19.00
pluralize
Specify the pluralized version of the word you need and if the number is greater than 1 it will pluralize it.
{{ 1 | pluralize: 'item', 'items' }} items {{ 4 | pluralize: 'item', 'items' }} item {{ cart.item_count | pluralize: 'item', 'items' }} Will output "item" if the number items in the customers cart is 1, if greater/less than 1 it will output "items"
product_img_url
Generates the product img url
{{ product.featured_image | product_img_url}} http://static.Haravan.com/files/Haravan_shirt_small.png?1255 Specify the img size {{ product.featured_image | product_img_url: 'thumb' }} http://static.Haravan.com/files/Haravan_shirt_thumb.png?1255
sort_by New
To be used in conjunction with {{ collection.url }} to sort a collection by best-selling, price-ascending, price-descending, title-ascending, title-descending, created-ascending, created-descending. Check out this liquid snippet.
{{ collection.url | sort_by: 'price-ascending' }} /collections/frontpage?sort_by=price-ascending
script tag
Generates a script tag
{{ 'shop.js' | asset_url | script_tag }} <script src="http://static.Haravan.com/files/assets/shop.js" type="text/javascript"></script>
stylesheet_tag
Generates a stylesheet tag
{{ 'shop.css' | asset_url | stylesheet_tag }} <link href="http://static.Haravan.com/files/assets/shop.css" rel="stylesheet" type="text/css" media="all" />
url_for_type
This filter creates an url for a type name by transforming it to a handle and adding the appropriate directory in front of it to make the url work.
{{ "Used car" | url_for_type }}/collections/types?q=Used+car
url_for_vendor
This filter creates a url for a vendor name by transforming it to a handle and adding the appropriate directory in front of it to make the url work.
{{ "Armani" | url_for_vendor }} /collections/vendor?q=Armani
weight_with_unit
Formats the product variant's weight
{{ product.variants.first.weight | weight_with_unit }} 44.0 kg
within
Used to indicate that the filtered url of a passed in object
{{product.url | within: collection }}

Template variables


blog.liquid

blog.id
Returns the id of this blog.
blog.handle
This is the accessor for this blog. It is usually the blog's title in underscore with every blank space replaced by a hyphen.
blog.title
Returns the title of this blog (set in Haravan)
blog.articles
Returns all of the blog's articles.
blog.articles_count
Returns the count of all of the blog's articles.
blog.url
Returns the relative URL of the blog.
blog.comments_enabled?
Returns true if comments are enabled for this blog, false otherwise.
blog.moderated?
Returns true if this blog is moderated, false otherwise.
blog.next_article
URL of the next (older) post. It returns false if there is no next article.
{% if blog.next_article %}
{{ 'next post >>' | link_to: blog.next_article }}
{% endif %}
blog.previous_article
URL of the previous (newer) post. It returns false if there is no next article.
{% if blog.previous_article %}
{{ '<< previous post' | link_to: blog.previous_article }}<br/> {% endif %}
blog.all_tags
Returns all the tags of the blog
<ul>
{% for tag in blog.all_tags %}
{% if current_tags contains tag %}
<li class="{{ tag | handleize }} current">{{ tag | link_to_tag: tag }} - current tag</li>
{% else %}
<li class="{{ tag | handleize }}">{{ tag | link_to_tag: tag }}</li>
{% endif %}
{% endfor %}
</ul>

The snippet below works for both article.liquid and blog.liquid

{% if blog.all_tags != blank %}
<h2>Categories</h2>
<ul>
{% for tag in blog.all_tags %}
<li>
<a href="{{ shop.url}}/blogs/{{ blog.handle }}/tagged/{{ tag | handleize }}">{{ tag }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
blog.tags
Returns all tags of all blogs on in this particular collection which match the current view.
This means that if the current view is filtered to only articles with a certain tags this variable will hold all the tags these remaining articles actually have.

article.liquid

article.excerpt_or_content
Returns article.excerpt of an article if it exists. Returns article.content if an excerpt does not exist for the article.
article.user.account_owner
Returns "true" if the author of the article is the account owner of the shop. Returns "false" if the author is not the account owner.
article.user.bio
Returns the bio of the author of an article. This is entered through the Staff members options on the Account page.
article.user.email
Returns the email of the author of an article. This is entered through the Staff members options on the Account page.
article.user.first_name
Returns the first name of the author of an article. This is entered through the Staff members options on the Account page.
article.user.last_name
Returns the last name of the author of an article. This is entered through the Staff members options on the Account page.
article.user.homepage
Returns the homepage of the author of an article. This is entered through the Staff members options on the Account page.
article.id
Returns the id of this article.
article.title
Returns the title of this article.
article.author
Returns the name of the author of this article.
article.content
Returns this article's content (the actual article).
article.created_at
Returns the date/time of when this article was created.
article.published_at
Returns the date/time of when this article was last published. Different from article.created_at if you import blog posts or hide/show a blog post.
article.url
Relative url where the blog can be found. Will append #article-id as anchor so that the page should automatically scroll to the corresponding article.
article.comments
Returns all published comments for this article if comments are enabled for the blog that this article belongs to. Otherwise, returns an empty array.
article.comments_count
Returns the number of published comments for this article.
article.comment_post_url
Relative url where comments are listed for this article.
article.comments_enabled?
Returns true if comments are enabled for the blog that this article belongs to, otherwise returns false.
article.moderated?
Returns true if the blog that this article belongs to is moderated, otherwise returns false.
article.excerpt
Renders the article's excerpt {% for article in blog.articles %}
{% if article.excerpt == blank %}
The article has no excerpt so let's truncate the text instead:
{{ article.content | strip_html | truncate: 30 }}
{% else %}
Here is the article excerpt
{{ article.excerpt }}
{% endif %}
{% endfor %}
article.tags
Returns all the tags for an article
comment.id
Returns the id of this comment.
comment.author
Returns the author of this comment.
comment.email
Returns the e-mail address of the author.
comment.content
Returns the body of the comment (in html).
comment.status
Returns the status of the comment. Will be one of 'unapproved', 'published', 'removed', or 'spam'.
comment.url
Relative url where the article can be found. Will append the comment's id as anchor so that the page should automatically scroll to the corresponding comment.

collection.liquid

collection.current_type
Returns the product type on a /collections/types?q=TYPE collection page. For example, you may be on the automatic Shirts collection, which lists all products of type 'Shirts' in the store: myshop.Haravan.com/collections/types?q=Shirts. {% if collection.current_type %}
We are on an automatic product type collection page. The product type is {{ collection.current_type }}.
{% endif %}
We are on an automatic product type collection page. The product type is Shirts.
collection.current_vendor
Returns the vendor name on a /collections/vendors?q=VENDOR collection page. For example, you may be on the automatic Haravan collection, which lists all products with vendor 'Haravan' in the store: myshop.Haravan.com/collections/vendors?q=Haravan. {% if collection.current_vendor %}
We are on an automatic product type collection page. The product type is {{ collection.current_vendor }}.
{% endif %}
We are on an automatic product vendor collection page. The product type is Shirts.
collection.default_sort_by
Returns the sort order of the collection, which is set in the collection pages of the Admin.
collection.image
Returns the collection image. Use the img_url filter to link it to the image file on the Haravan CDN. Check for the presence of the image first.
collection.image.src
Returns the relative URL to the collection image.
collection.template_suffix
Returns the name of the custom collection template assigned to the collection, without the collection. prefix or the .liquid suffix. Returns nil if a custom template is not assigned to the collection.
collection.id
Returns the id of this collection
collection.title
Returns the title of this collection
collection.handle
Returns this collection's handle, which is by default its title in lowercase. Whitespaces in the original title are replaced by dashes in the handle. The handle of a collection with the title "Winter Sale" would be "winter-sale".
collection.description
Returns the description of this collection
collection.all_types
Returns a list of all unique product types in the collection <ul>
{% for product_type in collection.all_types %}
<li class="{{ product_type | handleize }}">
{{ product_type | link_to_type }}
</li>
{% endfor %}
</ul>
collection.all_vendors
Returns a list of all unique vendors in the collection Shop by vendors:
<ul>
{% for product_vendor in collection.all_vendors %}
<li class="{{ product_vendor | handleize }}">
{{ product_vendor | link_to_vendor }}
</li>
{% endfor %}
</ul>
collection.products
Returns a collection of all products that are associated with this collection which match the current view. This takes into account things like paginate and selected tags.
collection.products_count
Returns a count of all of the products in this collection which match the current view. This takes into account things like paginate and selected tags.
collection.all_products
Returns all products that are associated with this collection. Default limit is 50, use pagination for more products
collection.all_products_count
Returns a count of all of the products in this collection.
collection.tags
Returns all tags of all products on in this particular collection which match the current view. This means that if the current view is filtered to only products with a certain tags this variable will hold all the tags these remaining products actually have.
collection.all_tags
This shows all tags associated with the collection.
collection.next_product
These methods are available if you scope your product pages to a certain collection.
collection.previous_product
These methods are available if you scope your product pages to a certain collection.
collection.url
Returns the url for the specific collection.

pages.liquid

page.published_at
Returns the timestamp of when the page was created. Use the date filter to format the timestamp.
page.template_suffix
Returns the name of the custom page template assigned to the page, without the page. prefix nor the .liquid suffix. Returns nil if a custom template is not assigned to the page.
page.id
Returns the id of this page.
page.handle
This is the accessor for this page. It is usually the page's title in underscore with every blank space replaced by a dash.
page.title
Returns the title of this page
page.content
Returns the content of this page.
page.url
Relative url where the page can be found.
page.author
Returns the author of this page.

Images

image.attached_to_variant?
Returns true if the image has been associated with a variant. Returns false otherwise. This can be used in cases where you want to create a gallery of images that are not associated with variants.
image.variants
Returns the variant object(s) that the image is associated with.
image.id
The image unique ID.
image.product_id
The id of the product the image belongs to. Returns the same value as product.id
image.position
The position of the image among other images of the product. The first image (featured) returns the value "1"
image.src
The relative path to the product image. It must be used in conjunction with the product_img_url filter. Returns the same value as {{ image }} {{ image.src | product_img_url: 'original' }}
image.alt
The description of the image. If image.alt is blank it will render product.title

Customers

customer.last_order
Returns the last order placed by the customer.
customer.name
Returns the full name of the customer.
customer.orders
Returns an array of all orders placed by the customer..
customer.orders_count
Returns the total number of orders a customer has placed.
customer.recent_order
Returns the most recent order placed by the customer.
customer.tags
Returns the list of tags associated with the customer.
customer.total_spent
Returns the total amount spent on all orders.
customer.accepts_marketing
Returns true or false if customers accepts marketing
customer.addresses
Use in a loop statement in conjunction with "address.[variable]"
{% for address in customer.addresses %}
{{ customer_address.first_name }}
or {{ customer_address.phone }}
{% endfor %}
customer.addresses_count
Total number of addresses for this customer
customer.default_address
Use in a loop statement in conjunction with "address.[variable]"
{% for address in customer.default_address %}
{{ customer_address.first_name }}
or {{ customer_address.phone }}
{% endfor %}
customer.email
Returns customer email
customer.first_name
Returns the first name of the customer
customer.has_account
Returns true or false if the customer has an account
customer.id
Returns the customer id
customer.last_name
Returns the last name of the customer

Template variables


Product.liquid

product.first_available_varian
Returns the [variant](/themes/liquid-documentation/objects/variant/) object of the first product variant that is available for purchase. In order for a variant to be available, its variant.inventory_quantity must be greater than zero or variant.inventory_policy must be set to continue. A variant with no inventory_policy is considered available.
product.selected_or_first_available_variant
Returns the variant object of the currently-selected variant if there is a valid ?variant= query parameter in the URL. If there is no selected variant, the first available variant is returned. In order for a variant to be available, its variant.inventory_quantity must be greater than zero or variant.inventory_policy must be set to continue. A variant with no inventory_management is considered available.
product.id
Returns the id of this product
product.title
Returns the title of this product
product.handle
Returns the handle of this product
product.type
Returns the type of this product, e.g. "snowboard", "headphones"
product.vendor
Returns the vendor of this product, e.g. "Sony", "Apple"
product.price
Returns the price for this product. By default this is the minimum price.
product.price_min
Returns the minimum price for this product.
product.compare_at_price_min
Returns a "compare at" price, e.g. recommended retail price for the least expensive variant of this product.
product.price_max
Returns the maximum price for this product.
product.compare_at_price_max
Returns a "compare at" price, e.g. recommended retail price for the most expensive variant of this product.
product.price_varies
Returns true if the product's variants have varying prices. Returns false if all variants have the same price.
product.compare_at_price_varies
Returns true if the compare_at_price_min is different from compare_at_price_max
product.url
Returns the url of this product. You need this for hyperlinking to this product's detail page from anywhere else in the store
product.featured_image
Returns the filename with a relative path of the featured image.
product.images
Returns a collection of all image filenames for this product. {% for image in product.images %} {{ image.src | product_img_url: 'grande' }} {% endfor %}
product.description
Returns the description of this product.
product.content
Alias of product.description.
product.variants
Returns a collection of all of this product's variants.
product.available
Returns false if all variants' quantities are zero and their policies are set to "stop selling when sold out".
product.template_suffix New
If using a custom product template (like product.bike-landing.liquid) then it will return the name of the template (bike-landing)
product.selected_variant New
Returns the variant object if passed in through the url (ex: ?variant=123 would return "123").
product.selected_or_first_
available_variant New
Returns the variant objet if there is a ?variant= url parameter. If there is no param the first variant with inventory will be selected.
product.collections
Returns a list of collections a product is listed in.
product.tags
Returns a list of the product's tags (represented by simple strings).
product.options
Returns a list of the product's options. By default, there is always at least one option, but there can be up to three. You can do a check to see how many Options a product may have by using the size filter.
variant.barcode
Returns the variant's barcode.
variant.inventory_policy
Returns the string continue if the "Allow users to purchase this item, even if it is no longer in stock." checkbox is checked in the variant options in the Admin. Returns deny if it is unchecked.
variant.inventory_quantity
Returns the variant's inventory quantity.
variant.selected
Returns true if the variant is currently selected by the ?variant= URL parameter. Returns false if the variant is not selected by a URL parameter.
variant.url
Returns true if the variant is currently selected by the ?variant= URL parameter. Returns false if the variant is not selected by a URL parameter.
{{ variant.url }} http://my-store.myHaravan.com/products/t-shirt?variant=12345678
variant.weight_unit
Returns the unit for the weight configured on the variant. Works well paired with the weight_in_unit attribute and the weight_with_unit filter.
variant.weight_in_unit
Returns the weight of the product converted to the unit configured on the variant. Works well paired with the weight_unit attribute and the weight_with_unit filter.
variant.id
Returns the variant’s unique id
variant.title
Returns the concatenation of all the variant's option values, joined by " / ".
variant.price
Returns the variants price
variant.image
You can also use {{ variant.image.src }}, but you probably want to use {{ product.selected_or_first_available_variant.featured_image }} tag instead of variant.image
variant.compare_at_price
Returns the variant’s recommended retail price
variant.available
Returns whether the variant is available for sale or not.
variant.inventory_management
Returns the variant’s inventory tracking service
variant.inventory_quantity
Returns how many of this variants are in stock for this shop
variant.weight
Returns the weight of the variant
variant.sku
Returns the variant's SKU
variant.option1
Returns the value of option1 for given variant
variant.option2
If a product has a second option defined, then returns the value of this variant's option
variant.option3
If a product has a third option defined

Cart

cart.item_count
Returns the number of items currently in the shopping cart.
cart.items
Returns all items in the shopping cart. Each one is of the type Line_Item. You will want to iterate through the return value (see example)
cart.total_price
Returns the total of all the prices added up in your shopping cart.
cart.total_weight
Returns the total weight of all items in the cart combined. Weight is always returned as grams. Use weight or weight_with_unit from the filter library to display the actual weight in your preferred unit system.
cart.note
allows you the option of adding a note field to your checkout template. Usage of this feature is very flexible. The general idea is that you simply define an input field named “note” in the form that submits to ”/cart” in cart.liquid.
cart.attributes
The attributes property is similar to the note property above in that it is an optional field you can add to your shop’s checkout form. Simply define an input field named “attributes[]” and it will be captured automatically and displayed on the order detail page in your admin area.

Linklist

linklist.id
Returns the id of this linklist
linklist.title
Returns the title of this linklist
linklist.handle
Returns the handle of this linklist
linklist.links
Returns a collection of this linklist's links.
linklist.object
The object the link points to. If the link points to a product {{link.product.title}} will, for example, print the name of the product. This is a very powerful feature and can be used for many complex liquid tasks.
link.title
Returns the description of this link
link.active
Returns true or false if the link is active
{% for link in linklists.main-menu.links %}
<li>
<a {% if link.active %}class="active"{% endif %}>
{{ link.title }}
</a>
</li>
{% endfor %}
link.url
Returns the url of this link
link.type
Returns the type of the object in link.object, you can usecollection_link, http_link, product_link, relative_link, page_link, blog_link
{% if link.type == 'collection_link' %} {% endif %}
link.object
If you're pointing to a collection, then link.object is a collection object. If you're pointing to a product page, then link.object is a product object.
{% if link.type == 'collection_link' %}
{% if link.object.all_tags.size > 0 %}

Shop

shop.enabled_payment_types
Returns an array of accepted credit cards for the shop. Use the payment_type_img_url filter to link to the SVG image file of the credit card.
shop.metafields
Returns the shop's metafields. Metafields can only be set using the Haravan API .
shop.money_format
Returns a string that is used by Haravan to format money without showing the currency.
shop.money_with_currency_format
Returns a string that is used by Haravan to format money while also displaying the currency.
shop.password_message
Returns the shop's password page message.
shop.permanent_domain
Returns the .myHaravan.com URL of a shop.
shop.name
Returns a string with the shop's name
shop.email
Returns your store's email
shop.description
Returns a description of the site
{% if shop.description != blank and template == "index" %}
<meta name="description" content="{{ shop.description }}">
{% endif %}
shop.currency
Returns a string with the name of the currency (usually a 3 letter representation, e.g. USD) this shop uses.
shop.url
Returns a full url to your shop. Note: This depends on the primary address configured under preferences/DNS Administration
shop.domain
Returns the domain of your shop. Note: This depends on the primary address configured under preferences/DNS Administration
shop.products_count
Returns the number of products you have online.
shop.collections_count
Returns the number of collections you have created.
shop.vendors
Returns a list of unique product vendors <ul>
{% for product_vendor in shop.vendors %}
<li class="{{ product_vendor }}">{{ product_vendor | link_to_vendor }}</li>
{% endfor %}
</ul>
shop.types
Returns a list of all unique product types in the shop <ul>
{% for product_type in shop.types %}
<li>
{{ product_type | link_to_type }}
</li>
{% endfor %}
</ul>