Skip to content

Truncatewords ​

Shortens a string to a number of words. When the string has more words, the filter adds an ending. The default number is 3 and the default ending is ....

liquid
{{ string | truncatewords: number, ending }}

Example ​

liquid
{{ 'Ground coffee from Ethiopia' | truncatewords: 2 }}
{{ 'Ground coffee from Ethiopia' | truncatewords: 2, '--' }}

Output

html
Ground coffee...
Ground coffee--