truncatewords
Shorten a string to a specified word count and append an ellipsis after the last complete word.
Syntax
{{ string | truncatewords: words_count, ellipsis }}Example
{% assign desc = "Licensed residential electrician serving Greater Austin area" %}{{ desc | truncatewords: 4 }}Output
Licensed residential electrician serving...The truncatewords filter shortens a string based on word count rather than character count, ensuring that truncation occurs only at natural word boundaries without splitting individual words.
In programmatic SEO architectures, truncatewords creates readable article summaries or excerpt snippets for hub pages and directory listings. For example: {{ row.overview_text | truncatewords: 20 }}. This produces natural, human-readable teasers that preserve semantic meaning and look professionally edited on index pages.
Filters
- abs
- append
- at_least
- at_most
- capitalize
- ceil
- compact
- concat
- date
- default
- divided_by
- downcase
- escape
- escape_once
- first
- floor
- join
- last
- lstrip
- map
- minus
- modulo
- newline_to_br
- plus
- prepend
- remove
- remove_first
- replace
- replace_first
- reverse
- round
- rstrip
- size
- slice
- sort
- sort_natural
- split
- strip
- strip_html
- strip_newlines
- times
- truncate
- truncatewords
- uniq
- upcase
- url_decode
- url_encode
- where
- raw
- slugify
- number_format
