AVADA logo
Published on

How to Set Default Value in Filter in Shopify

403 words3 min read
  • Name

Would you like to set automatic messages with a flexible form on your front page? You want to maximize the satisfaction of the customer journey. Liquid has a default filter that can help you to establish the automation for your page. The tutorial guide you to set default value in filter.

Table of content

General information about Liquid {#general-information-about-liquid}

Liquid is one of the open-source template languages in Shopify. Liquid is used as the backbone of Shopify to upload dynamic content on the front page. Liquid has been sold since 2006 and now become a good source for a lot of hosted website application such as Jekyll, salesforce desk, and zendesk.

Liquid codes are divided into objects, tags and filters. Objects tell Liquid where to display content on a page. Objects and variable names are denoted by double curly braces. Filters change the output of a Liquid object. There are five main types of filters, including string, number, boolean, nil, and array. Tags create logic and control flow for a template. Tags begin with two curly braces and percent signs. Tags are classified into control flow, iteration, and variable assignment.

In addition, Liquid in Shopify has other filters to support you to upload dynamic content or set specific forms on your front page.

What is default filter {#what-is-default-filter}

Default filter sets a default value for any variable with no assigned value. The default filter can be used with strings, arrays, and hashes. The default value is given back if the variable resolves to nil or an empty string. Especially, the default value will not respond to a string consisting of whitespace characters.

How to Set Default Value in Filter {#how-to-set-default-value-in-filter}

For instance, you want to set default to customer name, then you should follow:


Dear {{ customer.name | default: "customer" }}


<!-- If customer.name is nil -->
Dear customer

<!-- If customer.name is "" -->
Dear customer

<!-- If customer.name is "   " -->


To sum up, default value assists in establishing default value for any variable with no assigned value. Liquid in Shopify supports default filters to set default formula for your website. We hope that the tutorial is helpful to you and let us know your problems, we will address them.

Exclusive Offer: Shopify Deal for PageFly Audience

Start Your Online Business with Shopify 12 Day Free Trial + Pay Only 1$ For Your First Month