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:
- 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.
- Keep and add
rel="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 this
urlizeFilter 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 combine
nofollowStrategy 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.