In the Anqi CMS multi-site management system, configuring a dedicated content display template for each site is the key to achieving brand differentiation, optimizing user experience, and meeting specific content display needs.The Anqi CMS, with its flexible architectural design, provides multiple ways to achieve this goal, whether it is from the overall site level or refined to specific content types, it can achieve a high degree of customization.
Understanding the template mechanism of Anqi CMS
Firstly, we need to understand how Anqi CMS organizes and manages templates. All sites share a core template management area, usually located under the system root directory./templateFolder. In this directory, you can create multiple independent template packages (also known as template themes), each package is an independent folder, containing a complete set of styles, scripts, images, and the most important.htmlTemplate file.
Each template package is defined by aconfig.jsonfile to specify its basic information, such as the template name (name), a unique package identifier (package), version number, description, and template type (template_typeThe template type determines whether the template is for responsive design, code adaptation, or independent PC and mobile versions.AnQiCMS uses a syntax similar to the Django template engine, making the writing of template files intuitive and powerful.
The core path of independent template configuration for multiple sites
AnQi CMS provides multi-level template configuration capabilities from global to local, ensuring that each site can have a unique appearance and functionality.
1. Bind a dedicated template when creating a new site
This is the starting point for implementing independent multi-site templates. When you go to the Anqi CMS backend to perform "multi-site management" and "add a new site", the system will provide an option for you to "select the template to be used for the new site".Here, you can start from/templateSelect one from all the installed template packages in the directory as the default theme for the new site.Once selected and created successfully, the site will completely use this template for content display.This means that even multiple sites running on the same server can present completely different visual styles and layouts as long as they are bound to different template packages.
2. Template directory structure and default content type template
Each template package has its recommended directory structure, for example:
index/index.htmlFor the home page of the site.{模型table}/detail.htmlFor the detail page of specific content models (such as articles, products).{模型table}/list.htmlFor the list page of specific content models.page/detail.htmlFor the detail page of a regular single page.- If mobile template is enabled, there will be an
mobile/subdirectory containing mobile exclusive template files.
These default template files are the basis of the specific site template package. This means that all articles within the same site, unless specially specified, will use the template package bound within.article/detail.htmlThis hierarchical design ensures the consistency of content display within the site.
3. Template coverage for specific content types
The strength of AnQi CMS also lies in its fine-grained template coverage mechanism.After selecting the default template at the site level, you can also specify a more personalized template for specific content.The priority of this mechanism is usually: the specified template for individual content items > the specified template for categories > the default template for the site.
Specify exclusive list templates for categories:In the "Content Management" under the "Document Category" settings, each category can be configured with a "Category Template" field. If you want the article list or product list page under a certain category to have a unique layout, you can fill in the corresponding template file name here (for example
download.html)。The system will prioritize using the specified template for rendering the content list under this category.In addition, you can also choose to apply this template setting to subcategories, so that lower-level categories inherit this setting.Specify a dedicated details template for a single document or product:In the "Content Management" "Add Document" or "Edit Document" interface, there will be a "Document Template" field. When you need a specific article or product detail page to have a unique display effect, you can directly enter the template filename here (for example
special_product_detail.html). This document will no longer use the default detail template of its category or site, but will use the exclusive template you specify.Specify an exclusive template for a single page:Similarly, the "Page Resources" under "Page Management" provides the "Single Page Template" field.This allows you to configure completely independent display templates for specific single pages such as 'About Us', 'Contact Information', etc., thus providing flexibility to meet different page requirements.
Useful Techniques in Template Creation
When creating independent templates for multiple sites, the following techniques can help you improve efficiency and maintainability:
- Utilize common code snippets:For elements such as headers, footers, sidebars, etc. that may be repeated on multiple pages or in multiple template packages, you can use
{% include "partial/header.html" %}Tag to introduce independent public files, avoid repetition. - Inherit the basic layout:apply
{% extends 'base.html' %}and{% block content %}Tags, you can design a basic layout (skeleton) and then let other templates inherit this layout, only rewriting the parts that need customization to maintain a unified style and reduce redundancy. - Use macros to simplify repeated elements:For some UI components with high repetition but different parameters, you can use:
{% macro %}Tags define reusable code blocks and call them where needed, such as{{ archive_detail(item) }}. - Mobile independent template:If your template type is the "PC+Mobile" independent mode, be sure to include in each template package's
mobile/Build the corresponding mobile template files under the directory and ensure a **browser experience on different devices.
Through the above multi-level configuration and flexible template mechanism, Anqi CMS can allow you to easily implement independent template configuration for each site under multi-site management, thereby effectively supporting diverse business needs and brand strategies.
Frequently Asked Questions (FAQ)
Q1: Have I created multiple sites, and will modifying a template package affect other sites?A1: It depends on whether other sites are also using the same template package.If you modify a site-specific template package, it will only affect that site.But if multiple sites share the same template package (the same template was selected when creating a new site), then any modifications to the template package will affect all sites using it at the same time.It is recommended to create and bind an independent template package for each site that needs an independent style to avoid unnecessary mutual influence.
Q2: Is there a set of default template naming rules in Anqi CMS specified in the background?A2: Yes, AnQi CMS supports a set of default template file naming rules. When you do not specify a template in the background for specific content items (such as documents, categories, single pages), the system will automatically search for these default-named template files. For example, the article detail page will try to find{模型table}/detail.html, article list page will search{模型table}/list.htmlor{模型table}/list-{分类id}.html, single page will searchpage/detail.htmlorpage/detail-{单页ID}.html. Understanding these rules helps you organize template files and implement template application without additional background configuration.
Q3: I want to use the same specific detail page template for all articles under a certain category (content model is "article"), how should I operate?A3: You can enter the "Content Management" -> "Document Category" interface on the Anqi CMS backend, find the corresponding category to edit.In the category editing page, there is a "document template" field.Enter the file name of the detail page template you want to use for all articles in this category (for examplearticle_special_detail.htmlAfter saving, all articles in this category (unless the article itself specifies a more specific template) will be displayed using this template uniformly.If you also want its child categories to inherit this setting, you can check the 'Apply to child categories' option.