Liquid: set a maximum number of words

Don't want to show your long product descriptions completely in an email? Use liquid to set a maximum word count.

Francine avatar
Written by Francine
Updated over a week ago

The truncate feature allows you to set a limit on the number of words. It can happen that the product title or description of one product is many times longer than another product. With truncate you can limit this.

With the liquidation below the product description is truncated after 5 words:

{{ product.description | truncatewords: 5 }}

With this setting, the product description is truncated, and three dots ( ... ) are added. It is possible to change these three dots to your own inspiration:

{{ product.description | truncatewords: 5, " etc." }}

In this case, it will show "etc." (note the space before the word). Want to show nothing at all after the product name abbreviation? You can do that, too:

{{ product.description | truncatewords: 5, "" }}

Did this answer your question?