How to configure the HTML content filtering rules for all sites in a multi-site environment?

Calendar 👁️ 64

In a multi-site operation environment, ensuring the content security and display consistency of all sites is one of the core tasks.Especially the filtering rules for HTML content, which are directly related to user experience, information security, and even search engine optimization.The Anqi CMS is a feature-rich system that provides us with flexible tools to manage these rules.To implement a unified configuration of HTML content filtering rules across multiple sites, we need to combine the built-in functions of the system and operational strategies to achieve the goal.

First, understand the basic settings of Anqi CMS in content processing is crucial.Each independent Anqi CMS site has its own "Content Settings" module, you can find it under the "Backend Settings" menu in the backend.This module provides some important options that can preliminarily define the HTML processing method of the site content.For example, the option 'Automatically filter external links' can help you control whether external links are allowed in the content and whether to add linksrel="nofollow"Property, this is very useful for SEO and preventing bad link introductions.At the same time, the setting of whether to download remote images also indirectly affects the embedded HTML image tags in the content. If you choose to download, the external images will be localized, reducing dependence on third-party resources and improving loading speed and security.In addition, settings such as automatic image compression, Webp format conversion, and thumbnail processing methods also constitute the basic filtering and optimization rules for content display.

However, it should be noted that these "content settings" are independently configured for each site.There is no central switch for 'one-click global application' in a multi-site environment to manage these rules across all sites.Therefore, to achieve 'unified configuration', we need to adopt a systematic strategy.

A high-efficiency strategy is to clearly define a set of standard 'content settings' specifications when planning a new security CMS site.When creating a new site or auditing an existing site, always configure its 'Content Settings' module strictly according to this specification.This requires us to invest some effort in the initial setup to ensure that all sites maintain consistent basic content filtering rules.For example, you can decide to automatically filter external links, download remote images, and unify the compression size and thumbnail processing method of images for all sites to ensure consistency in brand image and user experience.

In addition to the site-level "Content Settings", the powerful template engine of AnQi CMS also provides us with fine control over HTML filtering at the content output level.During the template creation process, we can use built-in filters to further purify and standardize HTML content. For example,striptagsThe filter can remove all HTML tags from HTML content, leaving only plain text, which is very useful for certain scenarios where only abstracts or plain text content is needed.removetagsThe filter is more flexible, you can specify which HTML tags to remove from the content, such as removing<script>/<iframe>Tags that may pose potential security risks, or remove redundant style tags to keep the content HTML concise.

For example, in your template file (such asdetail.htmlorlist.htmlIn the case of displaying document content, you can use these filters:

{# 假设archiveContent变量包含了HTML内容 #}
{# 移除所有HTML标签,只保留纯文本 #}
<div>{{ archiveContent|striptags }}</div>

{# 移除内容中的<script>和<iframe>标签,同时确保其余HTML内容被安全地解析 #}
<div>{{ archiveContent|removetags:"script,iframe"|safe }}</div>

{# 结合使用,先移除不需要的标签,再确保剩余HTML的安全显示 #}
<div>{{ archiveContent|removetags:"font,span"|safe }}</div>

Please pay special attention.safeThe use of filters. The Anqi CMS template engine defaults to escaping HTML content to prevent XSS attacks. If you useremovetagsAfter the filter is processed, in order for the remaining HTML tags to be normally parsed by the browser, it must be used|safeExplicitly inform the system that this content is safe and does not require escaping. If the content is used directly without proper filtering,|safeit may pose a security risk. Therefore, it is recommended that youremovetagsUse or after cleaning up the content|safe.

To unify this level of template filtering across multiple site environments, **the practice is to establish a set of shared basic templates or template components. For example, you can define apartial/content_display.htmlA segment that contains the universal filtering logic of all HTML content output. All specific templates of all sites are used to display article content when{% include "partial/content_display.html" with content=archive.Content %}In this way, once you need to adjust the HTML filtering rules, you only need to modify this centralized template fragment, and all sites that refer to it can take effect immediately, thereby realizing the unified management of filtering rules.

Finally, regular audits and content review mechanisms are also indispensable.Even with unified configurations and templates, human errors or new security vulnerabilities may still occur.Establish a content review process, conduct spot checks on published content, and regularly review the "content settings" and template usage of each site, providing multiple safeguards for a multi-site environment.

By implementing the above strategy, that is, unifying the initial configuration of 'Content Settings' at the site level, and achieving unified output control through standardized filters and template components at the template level, you can effectively and flexibly manage and unify the HTML content filtering rules in the multi-site environment of Anqi CMS, ensuring that each site maintains a high degree of consistency in terms of security and content presentation.


Frequently Asked Questions (FAQ)

Q1: Can the "Content Settings" "Automatic Link Filtering" feature in AnQi CMS completely block all malicious HTML code?

A1: The "Auto-filter External Links" feature is mainly aimed at processing external links that appear in the content (for example, blocking display or addingnofollowProperties), to control the direction of the link and SEO impact. It cannot completely prevent all types of malicious HTML code, such as embedded<script>tags,<iframe>Or other suspicious HTML structures. To comprehensively prevent such risks, you also need to use the templates in conjunction withstriptagsorremovetagsfilters and use them cautiouslysafefilters to ensure the safety of the content output.

Q2: If my site template does not use any HTML filtering or escaping tags when displaying article content, how will the content be displayed?

A2: The template engine of Anqicms defaults to escaping HTML content output to the page. This means that if your article content contains<p>Hello</p>Such HTML tags can be directly passed through in the template{{ archive.Content }}They will be escaped when output&lt;p&gt;Hello&lt;/p&gt;The user sees the literal HTML code, not the effect after it is parsed by the browser. If you want the HTML content to be normally parsed, you need to explicitly

Related articles

Does AnQiCMS's 'Fake Original' feature involve modifying the HTML structure of the article?

AnQiCMS (AnQiCMS) is a powerful content management system whose built-in "pseudo original" feature often piques the curiosity and attention of users.Many users will naturally think when using this convenient tool: Will this feature affect and modify the original HTML structure of the article?To answer this question, we need to deeply understand the operation mechanism of Anqi CMS and the positioning of its 'pseudo original' function.

2025-11-08

The `removetags` filter removes the tags, does it also remove the content inside the tags?

When using AnQiCMS for website content management and template development, we often encounter scenarios where we need to clean up or adjust the HTML structure in the content.Among them, the `removetags` filter is a very practical tool, but many users are concerned about how it works, especially whether it will remove the content inside the tags when removing tags.This article will deeply explore the behavior of the `removetags` filter in the AnQiCMS template engine and help everyone clearly understand its function.###

2025-11-08

How can AnQiCMS clean up the redundant HTML when my article content is copied and pasted from a Word document?

In content operation work, we often need to obtain materials from various sources, among which Word documents are the most common kind.However, directly pasting the content of a Word document into a website editor often brings along a lot of unnecessary redundant HTML code.This code may not only destroy the overall style of the website, affect the page loading speed, but may also have a negative impact on search engine optimization (SEO).

2025-11-08

What hooks or extension points does AnQiCMS provide to allow custom processing logic for HTML content?

AnQiCMS was designed with a deep understanding of the personalized needs of content display, therefore, it has given users a high degree of freedom in the presentation logic of HTML content.This is not just a pile of content, but a deep-rooted customized philosophy, the core of which lies in a powerful and flexible template engine.When you need to finely control every inch of the display content on the website front end, AnQiCMS provides a series of intuitive and efficient tools.AnQiCMS uses a template engine syntax similar to Django, which undoubtedly reduces the learning threshold for operators familiar with web development

2025-11-08

How to use AnQiCMS tool to batch clean imported HTML content during content migration?

When performing website content migration, we often encounter a difficult problem: the imported HTML content has inconsistent formats, redundant tags, and may even contain some outdated or incompatible code.These 'HTML clutter' not only affect the visual consistency of the website, but may also slow down the page loading speed, and even have a negative impact on search engine optimization (SEO).Fortunately, AnQiCMS has provided us with a set of efficient and flexible tools that can help us batch clean up the imported HTML content

2025-11-08

Why does the `escape` filter sometimes cause HTML entities to be doubly escaped?

When using AnQiCMS for website content management and template development, we may encounter some confusing display issues, one of which is the double escaping of HTML entities.This usually appears as HTML tags that should be displayed as formatted text on the page, but are instead become `&lt;`p & gt; `such visible characters, even worse & amp;lt;p&amp;gt;`. This phenomenon not only affects the visual appearance of the website, but may also cause the content to lose its original style

2025-11-08

How to ensure that the rich text content of AnQiCMS back-end editor is safe HTML when displayed on the front end?

In daily website content operation, we often use the rich text feature of the AnQiCMS backend editor to carefully arrange articles, product details, or single-page content to present more beautiful and attractive page effects.From setting title styles, inserting images, creating lists, to embedding videos, rich text editors bring us great convenience and creative freedom.However, behind these flexible formatting capabilities, there is also a hidden, non-negligible security issue - how to ensure that the content containing custom HTML structures is displayed safely and correctly on the front end of the website? After all

2025-11-08

In AnQiCMS, can you set a default HTML content filtering strategy to be applied to all new published content?

In AnQiCMS, content management is one of the core functions, and ensuring the quality and security of published content is a focus for many website operators.About whether it is possible to set a default HTML content filtering strategy to apply to all new published content?This is indeed a question worth discussing. From the features provided by AnQiCMS, the system has adopted a multi-dimensional strategy in content security and filtering, and some of its functions indeed have an impact on the HTML of new published content.### Core Feature Exploration

2025-11-08