Home > Shopify Development > Liquid strip: How to Remove Whitespace tabs, spaces, and newlines

Liquid strip: How to Remove Whitespace tabs, spaces, and newlines in Shopify

Sam Nguyen
Sam Updated: May 07, 2024

Share:

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

Shopify marketplace is one of the most promising markets for any online sellers. Every year there are millions of buyers coming to this marketplace to find what they want to purchase; therefore, its revenue is unbelievable. However, this Shopify marketplace is so competitive because there are tons of shops with multiple products in this. The reason why the Shopify is concerned is their functionalities and additional tools for the Shopify store owners.

Liquidity is one of the most effective tools for any online merchants. Although Liquid has just been launched by Shopify since 2006, it is developed to bring the best experiences to their users. Due to the open-source template, Liquid is getting more and more popular for the Shopify store owners. In other web applications, this Liquid also plays an important role in building their websites. Online merchants do not have to pay for their helpful functionalities. Especially, this tool is so useful to solve the dynamic data with the combination of the tags, objects, and filters. Without affecting the spaces between words, this following article How to modify footer.liquid in ShopifyLiquid strip: How to Remove Whitespace tabs, spaces, and newlines will help the Shopify store owners to delete their unwanted whitespace.

How to Remove Whitespace tabs, spaces, and newlines in Shopify

About Liquid filters

In Shopify store’s settings, Liquid filters is considered as a tool to change the Liquid object’s output. By contributing the theme output, the Liquid filters is within an output. It is possible to have multiple filters within an output. For the structure of a Liquid filter, it includes an object and its attribute. In addition, the form of the filter applied is at the end of the filter. For example, in this filter ``, there is an object “product” and the title as its attribute and upercase will be the form applied, which are separated by a |.

Sometimes the strings include many unexpected whitespaces which result from tabs, spaces, and newlines make their Liquid object’s output not appropriate. Therefore, users usually want to remove these spaces in their strings.

The way to remove whitespace tabs, spaces, newlines

Step 1: Input

For example below, there is a string like this {{ " So much room for activities! "}} which has many whitespaces on the left and right sides.

We should enter the string code like the following input at the end of the string.

Input

{{ "          So much room for activities!          " | strip }}

Step 2: Output

After entering the input, the output will be removed all the spaces on both sides of the above example:

Output

So much room for activities!

Conclusion

This article How to Remove Whitespace tabs, spaces, and newlines in Shopify which includes simple steps for even the beginners in Shopify to remove all the unexpected spaces. In addition, we hope that online sellers can have more understanding of Shopify as well as Liquid through our chain of articles like the following list:


Sam Nguyen is the CEO and founder of Avada Commerce, an e-commerce solution provider headquartered in Singapore. He is an expert on the Shopify e-commerce platform for online stores and retail point-of-sale systems. Sam loves talking about e-commerce and he aims to help over a million online businesses grow and thrive.

Stay in the know

Get special offers on the latest news from AVADA.