---
title: '|urlizetrunc'
description: like [`urlize`](/filters/urlize/), but truncates the link text.
date: '2026-08-02'
categories:
  - Filter
  - URL
canonical: https://www.djangotemplatetagsandfilters.com/filters/urlizetrunc/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#urlizetrunc
---

# |urlizetrunc

like [`urlize`](/filters/urlize/), but truncates the link text.

## Documentation

> ### Behavior Change in Django 7.0
> The default protocol for URLs without a scheme (e.g., `www.example.com`) will change from **HTTP to HTTPS** in Django 7.0.
> To adopt HTTPS behavior now, set `URLIZE_ASSUME_HTTPS = True` in your settings.

Like [`urlize`](/filters/urlize/), but truncates the link text to `n` characters.

Converts URLs in a string to clickable links by wrapping them in an `<a>` tag. It identifies URLs that begin with `http://`, `https://`, or `www`. It also converts syntactically valid email addresses.

### Variable

```django
html = '''Check out our Python training at
www.webucator.com/programming-training/python-training.cfm. If you
have any questions, email sales@webucator.com.'''
```

### Template

```django
{{ html|urlizetrunc:25 }}
```

### Result

```django
Check out our Python training at
<a href="http://www.webucator.com/programming-training/python-training.cfm" rel="nofollow">www.webucator.…</a>. If you
have any questions, email <a href="mailto:sales@webucator.com">sales@webucato…</a>.
```

The generated links will be **nofollow** links.

> ### Warning
> According to the [official documentation](https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#urlizetrunc), this filter does not play nice with text already marked up as HTML.

## Commentary

Like [`urlize`](/filters/urlize/), this would be more useful if it could be applied safely to text already marked up as HTML. Also, the truncated URLs can be just plain ugly.
