--- url: https://developer.youcan.shop/themes/filters/strings/truncatewords.md --- # 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, '--' }} ``` ::: tip Output ```html Ground coffee... Ground coffee-- ``` :::