<p>You can use any Twig in the dynamic title field. There are plugins that provide Twig filters to truncate text, but here’s how you can do simple truncation without any plugin.</p>

<pre><code>{{ object.myTextField|length &gt; 50 ? object.myTextField|slice(0, 50) ~ '...' : object.myTextField }}
</code></pre>

CC BY-SA 3.0
2016-06-30T18:37:22.020Z
2016-06-30T18:37:22.020Z
carlcs
<p>I am auto-generating entry titles based on a plain text field. Now, I would like to limit the characters the title contains of (e.g. 50 chars while the plain text field has 500 chars). How could I do that?</p>

<p>Thank you very much for your help.</p>

<titles><auto-generate>
How to truncate auto-generated entry titles?
# How to truncate auto-generated entry titles?

(Asked by: username_0 on 2016-06-30)

I am auto-generating entry titles based on a plain text field. Now, I would like to limit the characters the title contains of (e.g. 50 chars while the plain text field has 500 chars). How could I do that?

Thank you very much for your help.

**Tags:** titles, auto-generate

---

## 1 answers

### Answer by username_1 on 2016-06-30. Score: 8 | Accepted answer

You can use any Twig in the dynamic title field. There are plugins that provide Twig filters to truncate text, but here’s how you can do simple truncation without any plugin.
{{ object.myTextField|length > 50 ? object.myTextField|slice(0, 50) ~ '...' : object.myTextField }}


---

