Is there a global option in the AnQiCMS background settings that affects the behavior of `urlize` and `urlizetrunc`?

Calendar 👁️ 89

When using AnQiCMS to manage website content, we often encounter the need to automatically convert URLs or email addresses in text to clickable links.urlizeandurlizetruncIt is a powerful tool to achieve this function. They can not only automatically recognize links in text but also automatically add links after conversionrel="nofollow"Property, this is very useful for SEO optimization.

However, when using these filters, many friends may be curious: is there a global option in the AnQiCMS backend settings that can control them uniformlyurlizeandurlizetruncWhat behavior? For example, can you turn them on or off with one key, or set them uniformly?urlizetruncHow long is the truncation? Today, let's delve deeper into this issue.

Get to know in-depthurlizeandurlizetrunc

First, let's briefly review.urlizeandurlizetruncThese two tools.

  • urlizeFilterIt mainly scans text content, automatically identifies it, and converts the URLs (such ashttp://www.example.com/www.example.comevenexample.com) and email addresses (such as[email protected]Convert to HTML's<a>tags. The converted links will be prefixed withrel="nofollow"The attribute helps tell search engines not to pass PR values to these external links, thereby better controlling the flow of our website's weight.
  • urlizetruncFilter: withurlizeSimilar, it also has the function of automatically converting links. But on this basis,urlizetruncIt allows us to specify a number to truncate the text displayed for the link. If the original URL string exceeds the number we set, it will add an ellipsis at the truncation point....This makes the page display more tidy.

These filters are very flexible in use within the template, and we usually apply them to the variables that need to be processed like this:

{{ content|urlize|safe }}
{{ description|urlizetrunc:30|safe }}

Here|safeIs a feature of the Django template engine, used to inform the system that this content is safe and does not require HTML escaping to ensure that the link displays normally as a clickable HTML tag.

Explore global options: AnQiCMS backend settings analysis

With the question of 'Do we have global options?', we carefully reviewed the various settings of the AnQiCMS backend. AnQiCMS provides a rich set of configuration options, covering all aspects of the website, but justurlizeandurlizetruncIn terms of direct behavioral control, the situation is as follows:

  1. Global feature settings(help-setting-system.mdThis part is mainly responsible for website name, logo, filing number, copyright information, website address, multilingual settings, and custom global parameters. Here, no direct control was found.urlizeorurlizetruncTurn on, off, or truncate the length option.
  2. Content settings(help-setting-content.mdThis area focuses on content processing methods, such as whether to download remote images, whether to automatically compress large images, and how to handle thumbnails. There is a very relevant option here is“Is automatic filtering of external links enabled”.
    • If you choose“Do not filter external links”External links contained in the document will be retained, and the system willautomatically addrel="nofollow"Tag.
    • If you choose“Filter external links”The system will directly remove external links from the content.

This setting of 'Whether to automatically filter external links' does not directly controlurlizeorurlizetruncthe filter itself, but it does indeed affect all external links on the website (including those generated byurlizethe links) ofnofollowBehavior. It is worth noting that,urlizeThe filter is designed to automatically add,rel="nofollow"This means that even if "Content Settings" is selected to "Not filter external links" and external links are added at the same time,nofollow,urlizeIt will also ensure that the link it generates has this attribute. It can be said that,urlizeInrel="nofollow"It has a 'halo' on this point.

The conclusion is:At the AnQiCMS backend, there is currently not oneDirect Global OptionUnified ControlurlizeandurlizetruncThe specific behaviors such as 'whether to use', 'truncation length', etc. They are more often regarded as local tools for template rendering and need to be manually applied when used.

Why is there no direct global option?

This design is not accidental, it may hide AnQiCMS's considerations for flexibility and performance:

  • Flexibility first:The different areas of the website may have different requirements for link processing.For example, the comment section of the article detail page may want all external links to be truncated for display, while the friendship link page does not require truncation.If there is a global switch, it may limit this fine-grained control.
  • Context relevance: The truncation length of links, whether to automatically convert, etc., is often closely related to the specific context in which the content is located (such as the main text of an article, list description, comments section, etc.)Control at the template level, can better adapt to different scenarios.
  • Performance considerationIf all text content needs to be scanned and processed globally on the server, it may have an impact on the performance of the website.This kind of processing can be delegated to the template layer, which can be triggered as needed, making it more efficient.

**Practice and Suggestions

Since there is no direct global option, we are usingurlizeandurlizetruncAt that time, the following strategies can be adopted to maintain consistency and efficiency:

  1. Use as needed, rather than blindly applying:According to the actual needs of the content, it should be applied only where automatic link conversion is requiredurlizeorurlizetrunc. For example, they are very suitable to be used in places such as user comment sections, automatically fetched content blocks, etc.
  2. UtilizewithLabel uniform truncation lengthIf you want certain types of pages within the website (such as all article list summaries)urlizetruncThe truncated length should be consistent, and it can be specified in the template header or a common code snippet (such aspartial/header.htmlUse it in{% with %}Define a variable to store this length, and then refer to this variable whereverurlizetruncit is used.
    
    {% with link_truncate_length=30 %}
        {{ item.description|urlizetrunc:link_truncate_length|safe }}
    {% endwith %}
    
    This way, when you need to modify the truncation length in the future, you only need to change one place.
  3. Understand the meaning of the background "Content Settings".: Remember what is in the background "Content Settings".

Related articles

Does the `urlize` filter support recognizing and converting IP address formatted URLs (e.g., `http://192.168.1.1`)?

In the daily use of AnQi content management system (AnQiCMS), template filters are an important tool for processing and displaying data.Among them, the `urlize` filter is often used for its convenience, to automatically convert URLs and email addresses in text content into clickable hyperlinks, and to automatically add the `rel="nofollow"` attribute to these links. This is very useful for handling user-generated content (UGC) or automatically identifying links in article text.### `urlize`

2025-11-09

How to implement different URL parsing strategies for different content types (articles, products, pages) in AnQiCMS?

In AnQiCMS, applying different URL parsing strategies for different content types such as articles, products, and pages is a key step to optimizing website structure, improving search engine optimization (SEO) and enhancing user experience.AnQiCMS powerful pseudo-static rule management and flexible content model design, making this requirement easy to implement. ### The Basics of Content Model and URL Structure One of the core strengths of AnQiCMS lies in its 'flexible content model'.

2025-11-09

How to balance beauty and information integrity when displaying long URLs with the `urlizetrunc` filter?

In website operation, a beautiful user interface and complete information presentation are key to attracting and retaining visitors.Especially when dealing with URL links, we often encounter a dilemma: is it better to let the long link destroy the page layout, or to truncate it and possibly lose some information?A safe CMS provides a very practical solution, that is the `urlizetrunc` filter, which cleverly balances these two needs.

2025-11-09

Does the `urlize` filter also force the addition of the `rel="nofollow"` attribute to internal links?

When using AnQiCMS for content creation and template development, we often encounter issues related to link handling. One common and key question is whether the `urlize` filter will also force the addition of the `rel="nofollow"` attribute to site internal links when converting URLs in text to links?This is an indispensable detail for the website's SEO strategy.

2025-11-09

Does the `urlize` filter-generated link include the `title` or `alt` attributes of the original URL?

In Anqi CMS templates, the `urlize` filter can effectively convert URLs in text content into clickable HTML links.For many users, while using this convenient feature, they are also concerned about whether the generated link will automatically include `title` or `alt` attributes to enhance user experience or optimize SEO.

2025-11-09

How to make `urlize` output HTML links correctly without using the `safe` filter?

The AnQiCMS template system provides a solid foundation for content operations with its powerful functions and flexible customization.In daily content display, we often encounter the need to automatically convert URLs in plain text to clickable HTML links.The `urlize` filter is designed for this purpose, it can intelligently recognize URLs or email addresses in text and wrap them in `<a>` tags.However, a common practice when using the `urlize` filter is to pair it with the `|safe` filter

2025-11-09

The `urlize` filter does it attempt to verify the validity or accessibility of the URL?

In AnQiCMS (AnQiCMS) content operation, we often need to automatically convert text links or email addresses into clickable hyperlinks in the article text.To achieve this goal, the `urlize` filter is a very convenient and commonly used tool.However, many users might be curious whether this `urlize` filter, while converting links, would also try to verify the validity or accessibility of these URLs?In short, the answer is: **No**. `urlize` filter is in AnQiCMS

2025-11-09

How to flexibly adjust the truncation length when using `urlizetrunc`, for example, based on the device type?

How to ensure that information is presented in a**way to every visitor on the corporate website, which is the key to improving user experience and the effectiveness of content marketing.Especially when website content contains a large number of external links or long URLs, how to cleverly handle the display of these links so that they are both aesthetically pleasing and complete, while also adapting to different screen sizes of devices, has become a task that requires meticulous management.The `urlizetrunc` filter provided by AnQiCMS is the tool to solve this problem.

2025-11-09