twig-tips

Trunction

With SEOMatic

https://nystudio107.com/docs/seomatic/Using.html#helper-functions-seomatic-helper

{% set excerpt = seomatic.helper.truncateOnWord(entry.richText, 180) %}

{% set matrixText = seomatic.helper.extractTextFromField(entry.contentMatrix) %}
{% set excerpt = seomatic.helper.truncateOnWord(matrixText, 180) %}

With StringHelper

{% set stringHelper = create('craft\\helpers\\StringHelper') %}
{% set string = 'Lorem ipsum dolor sit amet' %}
{% set excerpt = stringHelper.safeTruncate(string, 10) %}