# truncate

Source: https://zotonic.com/docs/1962/truncate

URI: https://zotonic.com/id/1962

Language: en



Truncate a text to a maximum length.

The text is truncated to the maximum length specified with the argument. The text is always truncated at a word boundary, to truncate at a character boundary use <a href="/id/doc_template_filter_filter_truncatechars" class="doc-reference doc-reference-filter"><code>filter#truncatechars</code></a>. If the truncation is not after punctuation then the unicode ellipsis … character is appended.

For example:

```django
{{ value|truncate:8 }}
```

If the value is `hello world.` then the output is `hello…`.

Entities like `&amp;` are counted as a single character.

This filter is multibyte aware: Multi-byte UTF-8 characters are assumed to be non-breaking characters.

Truncating character
--------------------

An optional second argument defines which text will be added if the text is truncated:

```django
{{ value|truncate:8:" (more)" }}
```

If the value is `hello world.` then the output is `hello (more)`.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1962?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1962?language=en>)
