Home > Shopify Development > Liquid prepend: How to Add a Suffix to a String

How to Add a Suffix to a String in Shopify

Thomas Nguyen
Thomas Nguyen Updated: July 21, 2023

Share:

Drive 20-40% of your revenue with Avada
avada email marketing

Have you ever forgotten inserting a name of a string in front of items of the string? Don’t worry, string filters will help you. By using prepend formula, your problem will disappear. The tutorial today will introduce you to add a suffix to a string.

Table of content

Introduction to Liquid

As you know, Liquid is classified into three subcategories consisting of objects, filters and tags. Liquid use objects to show the location of content on a page. Objects and variable names are denoted by double curly braces. Filters change the output of a Liquid object. Tags create logic and control flow for a template. Tags begin with two curly braces and percent signs. Tags can be divided into three types: control flow, iteration and variable assignment.

Prepend belongs to filters.

What is prepend

Prepend is a Liquid filter that allows you to add the specified string to the beginning of another string. The filter is useful because you can add the topic of the string, in front of elements of the chain. Therefore, visitors can easily follow the information.

How to add a suffix to a string

For instance, you have a chain of fruits including apples, oranges, bananas and you want to insert some fruit before that string to note the name of the chain.

Input


{{ "apples, oranges, and bananas" | prepend: "Some fruit: " }}

Output


Some fruit: apples, oranges, and bananas

Moreover, you are able to prepend variables:

Input


{% assign url = "example.com" %}

{{ "/index.html" | prepend: url }}

Output


example.com/index.html

Conclusion

To sum up, prepend helps to add a string before an available string. You are able to insert a topic to a list of items. Prepend belongs to filters in Liquid in Shopify. We hope that this tutorial is helpful and let us know your difficulties and we will address them.


As the CTO of Avada, a company specializing in Marketing Automation Platform, I have over 10 years of experience in software development. I have successfully led Avada's technical team in creating innovative products for our clients.

Stay in the know

Get special offers on the latest news from AVADA.