Liquid Flashcards

(118 cards)

1
Q

What is a handle?

A

A handle is a URL-friendly identifier automatically generated from an object’s title. It’s lowercase, spaces become hyphens, and special characters are removed.

```html
<a>{{ product.title }}</a>
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the {% assign %} tag?

A

Assigns a value to a new or existing variable. Commonly used to store strings, numbers, or arrays for later use.

```liquid
{% assign greeting = “Hello” %}

<p>{{ greeting }} world!</p>

~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the {% capture %} tag?

A

Captures everything between the tag into a variable, including multi-line text or HTML.

```liquid
{% capture my_content %}

<h2>Welcome!</h2>

<p>Thanks for visiting.</p>

{% endcapture %}
{{ my_content }}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What do {% if %} and {% unless %} tags do?

A

Conditional tags that execute code only if (or unless) a condition is true. Often combined with elsif and else.

```liquid
{% if product.available %}

<p>This product is in stock!</p>

{% else %}

<p>Out of stock</p>

{% endif %}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are operators in Liquid?

A

Used inside conditionals to compare values, check equality/inequality, or see if a string/array contains a value.

```liquid
{% if customer.tags contains “VIP” %}

<p>Welcome, VIP customer!</p>

{% endif %}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the {% for %} tag do?

A

Iterates over an array or collection. The forloop object provides details like forloop.index and forloop.first.

```liquid
{% for product in collection.products %}

<p>{{ forloop.index }}. {{ product.title }}</p>

{% endfor %}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What do {% break %} and {% continue %} tags do?

A

break stops the current loop immediately, while continue skips the rest of the current iteration and moves to the next.

```liquid
{% for i in (1..5) %}
{% if i == 3 %}
{% continue %}
{% endif %}
{{ i }}
{% endfor %}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does {% increment %} do?

A

Auto-creates and updates a counter variable. increment adds 1 each time it’s called; decrement subtracts 1.

```liquid
{% increment counter %} <!-- First call sets counter=1 -->
{% increment counter %} <!-- Next call sets counter=2 -->
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is whitespace control in Liquid?

A

Adding a hyphen in the tag syntax ({{- }}, {%- %}) removes surrounding whitespace/newlines, helping keep HTML clean.

```liquid
{% for product in collection.products -%}
{{- product.title -}}
{%- endfor %}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the shop object?

A

A global object with store details, such as shop.name, shop.domain, shop.currency, and more.

```html

<p>Store: {{ shop.name }}</p>

<p>Domain: {{ shop.domain }}</p>

~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the product object represent?

A

Represents a product in Shopify. Has attributes like title, price, variants, images, etc.

```html

<h1>{{ product.title }}</h1>

<p>Price: {{ product.price | money }}</p>

~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a collection in Liquid?

A

A grouping of products. Provides collection.title, collection.description, collection.products, etc.

```html

<h2>{{ collection.title }}</h2>

<p>{{ collection.description }}</p>

~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the cart object represent?

A

A global object that represents the customer’s cart, with cart.items, cart.total_price, cart.item_count, etc.

```html

<p>Items in cart: {{ cart.item_count }}</p>

<p>Total: {{ cart.total_price | money }}</p>

~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a line item?

A

Each unique product variant in the cart is a line item. Contains title, quantity, line_item.product, etc.

```liquid
{% for item in cart.items %}

<p>{{ item.title }} x {{ item.quantity }}</p>

{% endfor %}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does all_products do?

A

Lets you access any product by its handle: all_products[‘handle’]. Useful for referencing products not in the current context.

```liquid
{% assign my_product = all_products[‘red-shirt’] %}

<p>{{ my_product.title }}</p>

~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the page object?

A

Represents a standalone page (from Online Store > Pages). Offers fields like page.title and page.content.

```html

<h1>{{ page.title }}</h1>

<div>{{ page.content }}</div>

~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does the blog object contain?

A

A blog object containing multiple articles. Attributes include blog.title, blog.articles, etc.

```html

<h2>{{ blog.title }}</h2>

{% for article in blog.articles %}

<p>{{ article.title }}</p>

{% endfor %}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is an article in Liquid?

A

A single blog article, with properties like title, content, author, and more.

```html

<h3>{{ article.title }}</h3>

<div>{{ article.content }}</div>

<p>Author: {{ article.author }}</p>

~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does the customer object represent?

A

The logged-in customer object, if any. Contains customer.first_name, customer.orders, customer.email, etc.

```liquid
{% if customer %}

<p>Hello, {{ customer.first_name }}!</p>

{% endif %}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is a section in Liquid?

A

Represents a theme section, including section.settings and section.blocks. Used in .liquid section files.

```liquid
{% for block in section.blocks %}

<div>{{ block.settings.heading }}</div>

{% endfor %}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is a block in Liquid?

A

Each block inside a section. Has an ID, a type, and its own settings.

```html

<div>
{{ block.settings.content }}
</div>

~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What does the image object represent?

A

Represents an image, typically accessed via product.images or article.image. Provides src, alt, width, height.

```html
<img></img>
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is the media object?

A

An abstract object for product.media entries (images, videos, 3D models). Often includes a preview_image.

```liquid
{% for media_item in product.media %}
{% if media_item.media_type == ‘image’ %}
<img></img>
{% endif %}
{% endfor %}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What does the focal_point do?

A

Determines the important x/y region of an image so it stays visible when cropped.

```html

<p>Focal point: X={{ focal_point.x }}, Y={{ focal_point.y }}</p>

~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is a metafield?
A custom data field stored on Shopify resources (product, collection, etc.). Access with resource.metafields.namespace.key. ```html

{{ product.metafields.custom_fields.size_chart }}

```
26
What do settings provide access to?
Provides access to theme settings defined in settings_schema.json. Typically used for brand colors, text, etc. ```html ```
27
What is the template object?
Contains info about the current template (e.g. template.name), helpful for conditional logic based on template. ```html

Rendering template: {{ template }}

```
28
What is page_title?
The title of the current page, often used in or meta tags for SEO. ```html <title>{{ page_title }} ```
29
What are current_tags?
An array of tags currently filtering a collection or blog page. ```liquid {% for tag in current_tags %} {{ tag }} {% endfor %} ```
30
What are money filters?
Format numeric values as currency (e.g., money, money_without_currency). ```liquid {{ product.price | money }} ```
31
What are array filters?
Manipulate arrays (sort, filter, merge). Examples include map, sort, uniq, concat, where. ```liquid {% assign titles = collection.products | map: 'title' | sort %} ```
32
What are string filters?
Modify strings (uppercase, truncate, replace, etc.). Examples: upcase, downcase, truncate. ```liquid {{ "hello world" | upcase }} ```
33
What are color filters?
Adjust or extract color properties (e.g., color_darken, color_lighten). Often used on theme color settings. ```liquid {{ settings.header_color | color_lighten: 10 }} ```
34
What are localization filters?
Handle multi-language/currency tasks. Includes currency_selector, format_address, t. ```liquid {{ 'general.greeting' | t }} ```
35
What are math filters?
Perform arithmetic on numbers: plus, minus, times, divided_by, round. ```liquid {{ product.price | times: 2 | money }} ```
36
What are default filters?
Provide fallback values, like default and default_errors. ```liquid {{ customer.first_name | default: "Guest" }} ```
37
What are HTML filters?
Create HTML tags from strings or URLs. Includes link_to, script_tag, time_tag. ```liquid {{ "https://example.com" | link_to: "Visit Our Site" }} ```
38
What do metafield_tag and metafield_text do?
Output metafield data as HTML or plain text. ```liquid {{ product.metafields.custom_fields.info | metafield_text }} ```
39
What is the contains operator?
Checks if a string or array contains a specific substring/item. ```liquid {% if "hello world" contains "world" %}

Yes, it’s included.

{% endif %} ```
40
What does the form tag do?
Used within {% form %} tags for building forms (contact, account creation, etc.). Contains fields like form.errors, form.email. ```liquid {% form 'create_customer' %} {% endform %} ```
41
What is a linklist?
A navigation menu from the Shopify admin. Contains an array of link objects. ```liquid {% for link in linklists.main-menu.links %} {{ link.title }} {% endfor %} ```
42
What is a link?
An individual menu item within a linklist, with url, title, object, etc. ```html {{ link.title }} ```
43
What are routes?
Generates dynamic URLs for key pages (cart, account, search), so they remain valid if Shopify’s URL structure changes. ```html My Account ```
44
What do customer_login_link and customer_logout_link do?
Filters that generate login/logout URLs for customers. ```liquid {{ 'Log In' | customer_login_link }} {{ 'Log Out' | customer_logout_link }} ```
45
What does current_page represent?
The current page number in a paginated loop. Useful for building pagination UIs. ```html

Page {{ current_page }} of {{ paginate.pages }}

```
46
What is pagination?
Created by {% paginate %}. Splits a collection into multiple pages, providing paginate.parts, paginate.next, etc. ```liquid {% paginate collection.products by 8 %} {% for product in collection.products %} {{ product.title }} {% endfor %} {% endpaginate %} ```
47
What is content_for_additional_checkout_buttons?
Outputs offsite payment buttons (like PayPal) if enabled, typically displayed near 'Checkout.' ```liquid {{ content_for_additional_checkout_buttons }} ```
48
What does content_for_layout render?
Liquid placeholders that render the main content of the current template or the home page. ```liquid {{ content_for_layout }} ```
49
What does powered_by_link output?
Outputs a localized “Powered by Shopify” link. Often placed in the footer. ```html

{{ powered_by_link }}

```
50
What is the checkout object?
Available on the order status page or checkout.liquid (Shopify Plus). Includes info like checkout.line_items, checkout.total_price. ```html

Checkout ID: {{ checkout.id }}

```
51
What does search provide?
Provide data about search queries, results, and resource types. ```liquid {% if search.performed %}

Found {{ search.results_count }} results for "{{ search.terms }}"

{% endif %} ```
52
What is metafield_definition?
Used to store and retrieve custom data structures. Access entries via metaobject.system.handle or resource.metafields. ```liquid {{ metaobject.system.handle }} ```
53
What are selling_plan and selling_plan_group?
Related to subscriptions or recurring purchases. Provide details on recurring pricing or shipping intervals. ```liquid {% if product.selling_plan_groups.size > 0 %}

Subscription options available!

{% endif %} ```
54
What do robots and rule customize?
For customizing robots.txt directives (SEO/crawler instructions). Rarely changed in standard themes. ```liquid {% for group in robots.default_groups %} {% for rule in group.rules %} {{ rule.directive }}: {{ rule.value }} {% endfor %} {% endfor %} ```
55
What is the script object?
Contains info about Shopify Scripts (Shopify Plus feature for advanced cart/checkout logic). ```html

Script ID: {{ script.id }}

```
56
What do fulfillment and shipping_method provide?
Provide shipping and fulfillment data for orders. ```liquid {% for fulfillment in order.fulfillments %}

Tracking: {{ fulfillment.tracking_number }}

{% endfor %} ```
57
What are video, external_video, and model?
Advanced media types in product.media. Videos or 3D models can be rendered with appropriate tags. ```liquid {% if media_item.media_type == 'video' %} {% endif %} ```
58
What does localization handle?
Used for multi-language or multi-currency features, letting you display store content in different locales. ```html

Current locale: {{ localization.language.iso_code }}

```
59
What is routes (revisited for advanced usage)?
Useful for generating dynamic URLs to cart, account, search, ensuring future-proof links. ```html Go to Cart Search ```
60
What is a handle?
A handle is a URL-friendly identifier automatically generated from an object’s title. It’s lowercase, spaces become hyphens, and special characters are removed. ## Footnote If product.title = "Red Shirt", then product.handle = "red-shirt"
61
What is the assign tag?
The assign tag creates or updates a variable with a given value. ## Footnote {% assign greeting = "Hello" %}

{{ greeting }} world!

62
What is the capture tag?
The capture tag stores everything inside into a variable, including multi-line HTML or text. ## Footnote {% capture my_content %}

Welcome!

Thanks for visiting.

{% endcapture %} {{ my_content }}
63
What are if and unless tags?
They’re conditional tags that run code if (or unless) a condition is true. Often paired with elsif or else. ## Footnote {% if product.available %}

This product is in stock!

{% else %}

Out of stock

{% endif %}
64
What are operators (==, !=, >, <, >=, <=, and, or, contains)?
These are used inside conditionals to compare values or check if a string/array contains a substring/item. ## Footnote {% if customer.tags contains "VIP" %}

Welcome, VIP customer!

{% endif %}
65
What is the for tag (and forloop)?
The for tag iterates over an array or collection. The forloop object provides details like index or whether it’s the first/last item. ## Footnote {% for product in collection.products %}

{{ forloop.index }}. {{ product.title }}

{% endfor %}
66
What are break and continue?
Within a for loop, break immediately stops the loop, while continue skips to the next iteration. ## Footnote {% for i in (1..5) %} {% if i == 3 %} {% continue %} {% endif %} {{ i }} {% endfor %}
67
What are increment and decrement?
They automatically create and update a counter variable. increment adds 1, decrement subtracts 1. ## Footnote {% increment counter %} {% increment counter %}
68
What is whitespace control?
By adding a hyphen in the tag syntax ({{- }}, {%- %}), Liquid strips surrounding whitespace/newlines, helping keep HTML clean. ## Footnote {% for product in collection.products -%} {{- product.title -}} {%- endfor %}
69
What is the shop object?
The shop object contains store-wide info, such as shop.name, shop.domain, shop.currency, etc. ## Footnote

Store: {{ shop.name }}

Domain: {{ shop.domain }}

70
What is the product object?
Represents a single product. Common attributes include title, price, variants, images, and more. ## Footnote

{{ product.title }}

Price: {{ product.price | money }}

71
What is the collection object?
A grouping of products with attributes like collection.title, collection.description, and collection.products. ## Footnote

{{ collection.title }}

{{ collection.description }}

72
What is the cart object?
A global object representing the current shopping cart. Has cart.items, cart.total_price, etc. ## Footnote

Items in cart: {{ cart.item_count }}

Total: {{ cart.total_price | money }}

73
What is a line_item?
Each distinct product variant in the cart is a line_item. Includes title, quantity, line_item.product, etc. ## Footnote {% for item in cart.items %}

{{ item.title }} x {{ item.quantity }}

{% endfor %}
74
What is all_products?
Lets you reference any product by its handle: all_products['handle']. Helpful for cross-selling or static references. ## Footnote {% assign my_product = all_products['red-shirt'] %}

{{ my_product.title }}

75
What is a page object?
Represents a standalone page (from Online Store > Pages). Has fields like page.title, page.content. ## Footnote

{{ page.title }}

{{ page.content }}
76
What is a blog object?
Represents a blog in Shopify, containing multiple articles. Attributes include blog.title, blog.articles. ## Footnote

{{ blog.title }}

{% for article in blog.articles %}

{{ article.title }}

{% endfor %}
77
What is an article object?
A single blog article with properties like title, content, author, and more. ## Footnote

{{ article.title }}

{{ article.content }}

Author: {{ article.author }}

78
What is the customer object?
Represents a logged-in customer. Provides customer.first_name, customer.email, customer.orders, etc. ## Footnote {% if customer %}

Hello, {{ customer.first_name }}!

{% endif %}
79
What is a section object?
Used in .liquid section files, giving access to section.settings, section.blocks, etc. ## Footnote {% for block in section.blocks %}
{{ block.settings.heading }}
{% endfor %}
80
What is a block object?
Each block within a section. Has an ID, a type, and settings. ## Footnote
{{ block.settings.content }}
81
What is an image object?
Represents an image, often from product.images or article.image. Provides src, alt, width, and height. ## Footnote {{ image.alt }}
82
What is a media object?
A generic media entry in product.media. Could be an image, video, or 3D model. Usually includes a preview_image. ## Footnote {% for media_item in product.media %} {% if media_item.media_type == 'image' %} {% endif %} {% endfor %}
83
What is a focal_point?
The x/y coordinate that remains visible when an image is cropped. ## Footnote

Focal point: X={{ focal_point.x }}, Y={{ focal_point.y }}

84
What is a metafield?
A custom data field stored on Shopify resources. Accessed via resource.metafields.namespace.key. ## Footnote

{{ product.metafields.custom_fields.size_chart }}

85
What is settings?
Exposes theme settings from settings_schema.json. Often used for colors, text, or layout options. ## Footnote
86
What is a template object?
Contains details about the current template, like template.name or template.suffix. ## Footnote

Rendering template: {{ template }}

87
What is page_title?
The current page’s title, often used in the tag for SEO or browser tabs. ## Footnote <title>{{ page_title }}
88
What are current_tags?
An array of tags currently used to filter a collection or blog page. ## Footnote {% for tag in current_tags %} {{ tag }} {% endfor %}
89
What are money filters?
Format numeric values as currency (e.g., money, money_without_currency). ## Footnote {{ product.price | money }}
90
What are array filters?
Filters that manipulate arrays (e.g., map, sort, uniq, concat, where). ## Footnote {% assign titles = collection.products | map: 'title' | sort %}
91
What are string filters?
Filters that modify strings (uppercase, truncate, replace, etc.). Examples: upcase, downcase, truncate. ## Footnote {{ "hello world" | upcase }}
92
What are color filters?
Used to modify or extract color properties, such as color_darken, color_lighten, etc. ## Footnote {{ settings.header_color | color_lighten: 10 }}
93
What are localization filters?
Handle multi-language or multi-currency tasks. Includes currency_selector, format_address, t. ## Footnote {{ 'general.greeting' | t }}
94
What are math filters?
Perform arithmetic on numbers (e.g. plus, minus, times, divided_by, round). ## Footnote {{ product.price | times: 2 | money }}
95
What are default filters?
Provide fallback values, like default or default_errors. ## Footnote {{ customer.first_name | default: "Guest" }}
96
What are HTML filters?
Create HTML tags from strings or URLs. Examples: link_to, script_tag, time_tag. ## Footnote {{ "https://example.com" | link_to: "Visit Our Site" }}
97
What are metafield_tag and metafield_text?
Filters that output metafield data as HTML or plain text. ## Footnote {{ product.metafields.custom_fields.info | metafield_text }}
98
What is the contains operator in filters?
Checks if a string or array contains a specific substring/item. Often used in conditionals. ## Footnote {% if "hello world" contains "world" %}

Yes, it’s included.

{% endif %}
99
What is a form object?
Used inside {% form %} tags for building forms (contact, account creation). Has fields like form.errors, form.email. ## Footnote {% form 'create_customer' %} {% endform %}
100
What is a linklist?
A Shopify navigation menu. Contains an array of link objects. ## Footnote {% for link in linklists.main-menu.links %} {{ link.title }} {% endfor %}
101
What is a link object?
An individual menu item within a linklist, with url, title, object, etc. ## Footnote {{ link.title }}
102
What is routes?
A set of dynamic URLs (e.g. routes.cart_url) ensuring your theme remains valid if Shopify changes URL structures. ## Footnote My Account
103
What are customer_login_link and customer_logout_link?
Filters that generate login/logout URLs for customer accounts. ## Footnote {{ 'Log In' | customer_login_link }} {{ 'Log Out' | customer_logout_link }}
104
What is current_page?
The current page number in a paginated collection or array. ## Footnote

Page {{ current_page }} of {{ paginate.pages }}

105
What is pagination?
Created by {% paginate %}, splitting a collection into multiple pages. ## Footnote {% paginate collection.products by 8 %} {% for product in collection.products %} {{ product.title }} {% endfor %} {% endpaginate %}
106
What is content_for_additional_checkout_buttons?
Outputs offsite payment buttons (like PayPal) if available, typically placed near checkout. ## Footnote {{ content_for_additional_checkout_buttons }}
107
What are content_for_layout and content_for_index?
Placeholders that dynamically render the main content of a template or the homepage. ## Footnote {{ content_for_layout }}
108
What is powered_by_link?
Outputs a localized “Powered by Shopify” link, usually placed in a footer. ## Footnote

{{ powered_by_link }}

109
What is the checkout object?
Available in the order status page or checkout.liquid (Shopify Plus). Provides details like checkout.line_items, checkout.total_price. ## Footnote

Checkout ID: {{ checkout.id }}

110
What are search and predictive_search?
Objects that provide data about search queries, results, and resource types. ## Footnote {% if search.performed %}

Found {{ search.results_count }} results for "{{ search.terms }}"

{% endif %}
111
What are metafield_definition and metaobject?
Used to store and retrieve custom data structures in Shopify. Access entries via metaobject.system.handle or resource.metafields. ## Footnote {{ metaobject.system.handle }}
112
What are selling_plan and selling_plan_group?
Related to subscriptions or recurring purchases, detailing recurring pricing or shipping intervals. ## Footnote {% if product.selling_plan_groups.size > 0 %}

Subscription options available!

{% endif %}
113
What are robots and rule?
For customizing robots.txt (SEO/crawler instructions). Rarely changed in standard themes. ## Footnote {% for group in robots.default_groups %} {% for rule in group.rules %} {{ rule.directive }}: {{ rule.value }} {% endfor %} {% endfor %}
114
What is a script object?
Contains info about Shopify Scripts (Shopify Plus feature for custom cart/checkout logic). ## Footnote

Script ID: {{ script.id }}

115
What are fulfillment and shipping_method?
Provide shipping and fulfillment details on orders, such as tracking info or shipping costs. ## Footnote {% for fulfillment in order.fulfillments %}

Tracking: {{ fulfillment.tracking_number }}

{% endfor %}
116
What are video, external_video, and model?
Advanced media types in product.media for videos or 3D models. ## Footnote {% if media_item.media_type == 'video' %} {% endif %}
117
What is localization/country/shop_locale?
Used for multi-language or multi-currency setups, letting you display content in different locales. ## Footnote

Current locale: {{ localization.language.iso_code }}

118
What is advanced routes usage?
Using routes for dynamic URLs to cart, search, etc., ensuring future-proof links. ## Footnote Go to Cart Search