In the rapidly developing multi-site ecosystem of Anqi CMS, efficiency and consistency are always the focus of operators.For businesses managing multiple brand sites, sub-sites, or content branches, how to ensure the uniqueness of content and brand consistency while avoiding redundant work, ensuring unified management of common modules, and quick updates is undoubtedly a huge challenge.includeLabel.

include标签,as one of the core functions built by Anei CMS based on Go language and Django template engine syntax, it is not only a simple code snippet reference tool, but also a 'united front' for realizing the modularization, unified management, and efficient update of multi-site content modules.

English operations of multiple sites andincludethe emergence of

Imagine that you are running a brand website for ten different product lines, and each website requires a footer that includes the company's contact information, navigation menu, and copyright notice.If there is no unified management mechanism, you may need to rewrite the same code in ten different template files.Once the company's phone number changes, or the navigation structure needs to be adjusted, you will have to modify these ten files one by one, which is not only time-consuming and labor-intensive, but also prone to errors.

The multi-site management function of Anqi CMS is designed to enable independent management and content publishing of multiple sites through a unified backend, which greatly reduces repetitive work. However, when it comes to public elements at the template level, includeThe value of the label becomes prominent.It allows us to extract content modules that frequently appear and have similar structures across multiple sites (such as header navigation, footer copyright information, sidebars, contact information blocks, even specific ad placements or content recommendation modules) and manage them as independent template files.

includeHow to unify the management and update of public content modules

include标签的核心理念在于“Don’t Repeat Yourself”(DRY,不要重复自己)。“English”}]It allows us to dynamically embed the content of one template file into another template file.

  1. To achieve consistency in global templates:The most direct application is the unified header and footer. You can create a namedpartial/header.htmlandpartial/footer.htmlThe public template file, which includes the common structure and content of all sites. Then in the main template file of each site (such asindex.html/detail.html), simply use{% include "partial/header.html" %}and{% include "partial/footer.html" %}Cite them. This way, no matter how many sites you have, they will share the same header and footer. When it's time to update these common sections, just modifyheader.htmlorfooter.htmlThis file, all sites referencing it will take effect immediately, greatly enhancing the update efficiency and maintenance convenience.

  2. Dynamically adapt to specific site information:Public modules are not always completely static. For example, even if the header structure of all sites is the same, the displayed website name or contact number may vary from site to site. The Anqi CMS'sincludeLabel and the system built-insystemandcontactLabel配合,能够完美解决这一问题。您可以在partial/header.html中,通过{% system with name="SiteName" %}来动态获取当前站点的名称,或者通过{% contact with name="Cellphone" %}Display the contact phone number of the current site. This means that the sameheader.htmlFile, displayed at site A showing site A's name and phone number, and at site B displaying site B's information, no need to customize for each siteheader.htmlThis powerful dynamic adaptability is the key to achieving true 'unified management'.

    For example, a unified footer templatepartial/footer.htmlIt may look like this:

    <footer>
        <p>&copy; {% now "2006" %} {% system with name="SiteName" %}. All Rights Reserved.</p>
        <p>联系电话:{% contact with name="Cellphone" %}</p>
    </footer>
    

    This file can be accessed by all sitesinclude,and automatically display their website names and contact information.

  3. Flexible content module combination and customization: includeThe label supports passing variables.This means that you can inject some temporary, site-specific data when introducing a public module, thereby achieving more fine-grained control.partial/promo_banner.html,but different sites need to display different promotional copy, you can use{% include "partial/promo_banner.html" with promo_text="限时优惠!免费送货" %}.promo_banner.htmlInternal, can be accessed through{{ promo_text }}to display these input variables. If a site does not need to display promotional information, it can even omit theincludetag, or useif_existsParameters to avoid error due to file not existing.

  4. Promote modular development and team collaboration:Dividing large templates into multiple manageable small modules not only improves the readability and maintainability of the code, but also greatly promotes team collaboration.Different developers can be responsible for different public modules at the same time without interfering with each other.This is an effective way to improve development efficiency and reduce communication costs for enterprises with a large number of websites or those frequently updating their content.

Organization and benefits in practice

In the Anqi CMS, **the practice is to store all reusable template fragments in a specialpartial/directory, such asdesign-director.mdThe document mentions this. This maintains the clarity of the file structure and facilitates quick search and reference. Combinedextendstags (used to define the overall page layout skeleton) andincludeLabel (used for embedding specific content modules), you can build highly modular and easy-to-maintain template systems.

By intelligently applyingincludeTags, the security CMS has helped operators achieve a qualitative leap in multi-site management: it not only greatly reduces repetitive code writing work, ensuring high consistency in visual and functional aspects across all sites, but more importantly, it has elevated the efficiency of website updates and maintenance to an unprecedented level. Whether it is to quickly respond to market changes or to unify the brand image,includeLabels are an indispensable tool in the Aanqi CMS multi-site strategy.


Common Questions (FAQ)

1.includeTags andextendsWhat are the differences between labels in Aanqi CMS templates?

In simple terms,extendsTags are used to define the "skeleton" or "master" of a page, it specifies the overall layout structure of a page andblockLabel the area reserved for rewriting (overwriting) by child templates. A child template usually onlyextendsAn English parent template.includeTags are more like embedding a small 'building block' into any template (whether it's a parent template, child template, or otherincludeThe specific position of the incoming segment. It does not involve layout rewriting, but simply reuses code segments. So, you can first useextendsto build the page skeleton, and then useincludeFill various reusable content modules.

2. In a multi-site environment, using too manyincludetags whether it will affect website performance?

The AnQi CMS template engine handles