How does AnQiCMS automatically filter or process external links in article content and control their display on the front end?

Calendar 👁️ 85

In content operation, properly handling external links in article content is an important link, it not only relates to the SEO health of the website, but also affects the reading experience of users.AnQiCMS provides a flexible mechanism to help users automatically filter or handle external links, and supports control over the way the front-end is displayed.

Core Function: Automatic Processing Strategy for External Links

AnQiCMS provides convenient settings in the background, allowing users to manage external links in article content according to their own operational strategies. You can find them in the system background.Global SettingsbelowContent settingsOptions. Here, there is a key configuration item -Do you want to automatically filter external links.

This option provides two main ways of handling:

  1. Automatically remove external links:When you enable (check) the 'Automatic External Link Filtering' option, AnQiCMS will automatically detect and remove external links contained in the content when publishing or updating articles.This strategy is suitable for situations with extremely high requirements for content purity, or for those who want to strictly control "link overflow", such as some professional sites that do not want users to jump to third-party websites.
  2. Keep and addrel="nofollow"Tags:If you do not enable (uncheck) 'Whether to automatically filter external links', the system will take a milder but equally effective strategy. In this case, external links in the article will be retained, but AnQiCMS will automatically add links to these linksrel="nofollow"Property.nofollowThe tag tells the search engine that this link should not be considered as a "vote" or "endorsement" for the target page.This helps prevent "Link Juice Leakage" and effectively avoids SEO risks that may arise from linking to low-quality websites.At the same time, this method also retains the convenience of users clicking on external resources, balancing SEO and user experience.

By making simple configurations in the background, AnQiCMS can automatically complete these complex processes, greatly reducing the burden on content editors and ensuring the standardization of website content.

Refined control of the front-end display mode: Make good use of template filters

In addition to the automatic processing mechanism in the background, AnQiCMS also allows for further control of the display of external links on the front-end template level through flexible filters (Filters), thereby enhancing the user experience.

In the content display, you may encounter two situations: one is that the content already has standardized<a>Label link; another is that the article content only contains plain text URL addresses, which need to be converted into clickable links. The AnQiCMS template system providesurlizeandurlizetruncThese filters solve these problems.

  • urlizeFilter:When your article content contains plain text URLs such ashttps://www.example.comorwww.example.com)urlizeThe filter can intelligently identify these texts and automatically convert them into clickable HTML<a>Tags. More notably,urlizeThe filter also automatically adds to these links while creating themrel="nofollow"propertyThis forms an organic whole with the content settings in the background, further enhancing SEO-friendliness.

    In the template, you can use it like thisurlizeFilter to process article content:

    {# 假设 archiveContent 变量包含了文章的纯文本内容,其中可能含有URL #}
    <div>
        {{ archiveContent|urlize|safe }}
    </div>
    

    Here|safeIs indispensable, it tells the template enginearchiveContentafterurlizeThe generated HTML is safe and can be output directly, avoiding re-escaping.

  • urlizetruncFilter:For particularly long URL addresses, if displayed directly, it may affect the aesthetics and readability of the page.urlizetruncFilter is onurlizeOn the basis of this, the function of truncating link text has been added. You can specify a length, and the link text exceeding this length will be truncated with an ellipsis....The end, thus keeping the page neat. Similarly, it will also automatically add links generated.rel="nofollow"Property.

    For example, truncate the link text to 15 characters:

    {# 长的URL会被截断显示,但链接功能不变 #}
    <div>
        {{ archiveContent|urlizetrunc:15|safe }}
    </div>
    

These filters are usually applied to display the main content of the article (such asarchive.Contentorpage.ContentThe template location. By cleverly using them, it can not only ensure proper SEO handling of external links, but also significantly enhance the visual neatness and user-friendliness of the website content.

Regarding making external links open in a new window (i.e., addingtarget="_blank"), although AnQiCMS 'surlizeThe filter itself does not provide direct parameters to control this, but as a template developer, you can dynamically set this for allrel="nofollow"Add a linktarget="_blank"Attribute, or according to the actual situation, manually add this attribute when editing content to ensure a good user experience.

Practical suggestion: balance SEO and user experience

When configuring AnQiCMS to handle external links, it is recommended to choose according to your website type and operational objectives:

  • For websites that focus on original content, want users to focus on the site, or have strict requirements for content security, consider enabling the "Automatic Link Filtering" feature to ensure content purity.
  • For websites that require referencing external resources, providing more information sources, or allowing users to post links in the comment section, do not check "Auto-filter external links" and combinenofollowStrategy is the more appropriate choice. This maintains the richness of the content while controlling SEO risks.
  • It is always recommended to use in front-end templates.urlizeorurlizetruncA filter to process possible plain text URLs, ensuring the clickable nature of links and the correct addition of SEO attributes.

Through these features provided by AnQiCMS, you can find a proper balance between SEO benefits and user experience, ensuring that the website content is both professional and easy to browse.


Frequently Asked Questions (FAQ)

1. Does the link added manually to the article content affected by the 'Do you want to automatically filter external links' setting?

Yes, it will be affected.Whether you manually add links in the editor or insert links through other means, as long as they exist in the main content of the article, the system will process them according to the settings of whether to automatically filter external links.rel="nofollow"Property.

How to make all external links in the article open in a new window (tab)?

AnQiCMS'urlizeandurlizetruncThe filter does not add by default.target="_blank"Property. To make all external links open in a new window, you can add a piece of code in the public JavaScript file of the website to detect allrel="nofollow"(or you can use your own custom marker) of<a>tag, and add it dynamicallytarget="_blank". For example:

document.addEventListener('DOMContentLoaded', function() {
    var externalLinks = document.querySelectorAll('a[href^="http"]:not([href*="' + window.location.hostname + '"])');
    externalLinks.forEach(function(link) {
        link.setAttribute('target', '_blank');
        link.setAttribute('rel', 'noopener noreferrer'); // 推荐同时添加此属性以增强安全性
    });
});

Please note that the above code needs to be adjusted according to the actual needs and link structure of your website.

3. If the article content already has many external links, do I want to batch modify or delete a specific type of link, does AnQiCMS have a tool to support this?

AnQiCMS provides “Full site content replacement”function, which can help you batch process article content. You can find it in the background ofcore features and highlightsFind the relevant description. Use this feature to set specific keywords or link patterns to replace them with new ones.

Related articles

How to add categories for image resources in AnQiCMS and manage the front-end display according to categories?

In AnQiCMS (AnQiCMS), effectively organizing and managing your website image resources is the key to improving operational efficiency and front-end display quality.The image classification function not only makes the background management work orderly, but also provides a flexible foundation for the presentation of front-end page content.Below, let's take a detailed look at how to add categories for image resources in AnQiCMS and cleverly manage the display on the front end.

2025-11-09

How does the `ContentTitles` tag in AnQiCMS help generate and display the table of contents on the article detail page?

In daily content creation and website operation, we often encounter long articles with a large amount of information.This kind of article is rich in content, but without a clear navigation structure, readers are easily lost in the ocean of text and find it difficult to quickly locate the part they are interested in.This not only affects the reading experience, but may also reduce the effective communication of the content.

2025-11-09

How to use the `macro` tag in AnQiCMS to define reusable content display components and improve template efficiency?

In AnQiCMS template development, we often encounter situations where we need to repeatedly write the same or similar code blocks, such as article cards on the website, product display blocks, or buttons with specific styles.This repeated code not only reduces development efficiency, but also makes subsequent maintenance and modification more cumbersome.Luckyly, AnQiCMS provides the `macro` tag, which allows us to define reusable content display components, managing template code like writing small functions, thereby greatly enhancing template efficiency and maintainability.What is

2025-11-09

How does AnQiCMS implement template inheritance through the `extends` tag to simplify the maintenance of page structure display?

In website operation and content management, maintaining a clear, unified, and easy-to-maintain website structure is an important challenge.Especially when there are many pages on a website, repeated page elements (such as headers, footers, navigation bars) would undoubtedly require a lot of time and effort to modify one by one.AnQiCMS (AnQi CMS) is precisely through its powerful template inheritance mechanism, especially the use of the `extends` tag, that helps us efficiently solve this problem.

2025-11-09

How to use the `truncatechars` or `truncatewords_html` filter to truncate text or HTML content and add an ellipsis for display?

When operating a website, we often encounter situations where we need to display long content, but the page space is limited.For example, on the article list page, we usually only want to display the abstract of the article; on the product detail card, we may only want to show a brief description.If this content is not processed, it may overflow the container, destroy the page layout, and affect the user experience.The AnQi CMS knows the importance of content display and provides us with powerful template functions.

2025-11-09

How does AnQiCMS's `urlize` filter automatically convert URLs and email addresses in plain text to clickable links?

In website content operation, we often need to include some URLs or email addresses in the articles or descriptions.In traditional methods, this information is often just plain text, and users need to manually copy and paste to access it, which undoubtedly increases the user's operation cost and affects the interactivity of the content. 幸运的是,AnQiCMS cleverly goes through its powerful template filter mechanism, providing us with an elegant solution - that is the `urlize` filter.

2025-11-09

How to flexibly control the conditional display and loop output of content in AnQiCMS templates through `if`, `for`, and other logical tags?

In AnQiCMS, templates are the core of building the appearance and displaying content of a website.It is crucial to be proficient in using the logical tags in the template to make the content of the website more flexible and intelligent.This is the two great tools of dynamic content display, `if` conditional judgment and `for` loop output tags.They allow you to display or hide content based on specific conditions, efficiently traverse and output a series of data, thereby creating highly customized and responsive frontend pages to meet user needs.

2025-11-09

Does AnQiCMS support displaying a custom shutdown prompt when the website is closed?

The website is in operation, and it is inevitable that there will be situations where the website needs to be temporarily closed, such as system upgrades, data maintenance, or business adjustments, etc.How can you clearly and professionally convey the current status of the website to visitors to avoid them seeing a stiff error page, which is particularly important.For users using AnQiCMS, the good news is that the system has fully considered this point and provided a very flexible setting function for the shutdown prompt information.Yes, AnQi CMS fully supports displaying your custom prompt information when the website is closed.

2025-11-09