urlizetruncFilter, it is the tool to solve this problem.

urlizetrunc: The basic skill of link beautification.

The AnQi CMS adopts a template engine syntax similar to Django, providing rich built-in tags and filters, making template development and content display flexible and efficient. Among them,urlizetruncFilter specifically used for automatically identifying URLs or email addresses in text, converting them into clickable<a>标签,and automatically adds themrel="nofollow"attributes, which is very beneficial for SEO optimization and external link management.

urlizetruncThe uniqueness lies in the fact that it allows you to specify a truncation length. When the displayed text of the URL exceeds this length, it will automatically add an ellipsis at the end....Truncate to avoid breaking the layout or affecting the reading experience due to overly long URLs.

For example, if there is a very long URL text in the template:

<p>访问我们的官方网站:{{ "http://www.example.com/products/category/detail/very-long-product-name-with-many-keywords"|urlizetrunc:30|safe }} 获取更多信息。</p>

This code will display it as:

`html

Visit our official website: