How to configure and manage multiple templates in AnqiCMS?

Calendar 👁️ 59

As an experienced AnQiCMS website operator, I am well aware of the importance of a flexible and powerful template system for displaying website content and improving user experience.AnqiCMS provides high flexibility in template configuration and management, meeting the various needs from personal blogs to enterprise-level multi-site operations.Below, I will elaborate on how to configure and manage multiple templates in AnqiCMS, helping you make full use of this powerful feature.

Configure and manage multiple templates in AnqiCMS

In AnqiCMS, templates are not just the appearance of the front-end page, but also the core of content display logic.The system allows you to easily configure and switch between multiple sets of templates, and customize exclusive templates for specific content, thereby achieving personalized and differentiated operation of the website.

Understand the basic AnqiCMS template

AnqiCMS template files are all with.htmlsuffix, and are uniformly stored in the root directory of the system./templateIn the folder. Each independent template should have its own subdirectory in this directory. Similar to the Django template engine, AnqiCMS templates use double curly braces{{变量}}output variables, while logical operations such as conditional judgments and loop control are used{% 标签 %}The form. The CSS styles, JavaScript scripts, and static resources such as images that the template depends on should be stored separately./public/static/In the directory, to maintain the neat and structured template directory.

AnqiCMS supports various template types, including adaptive (responsive) templates, code adaptation (providing different HTML for different devices) templates, and PC + mobile independent site mode. Especially in the latter two modes, you can create a template within the template directory.mobileSubdirectory for storing dedicated mobile templates, achieving more refined device adaptation.

Template directory structure and configuration file

The core of each template is its/templatea standalone folder under the directory, as well as the folder withinconfig.jsonthe configuration file. This file is the key to the system's identification and management of templates.

config.jsonThe file contains basic information and usage status of the template, its typical structure is as follows:

{
	"name": "默认模板",
	"package": "default",
	"version": "1.0",
	"description": "系统默认模板",
	"author": "kandaoni.com",
	"homepage": "https://www.kandaoni.com",
	"created": "2022-05-10 22:29:00",
	"template_type": 0,
	"status": 0
}

Among them,nameIs the display name of the template,packageIs the name of the template folder (must be English and numbers),template_typeDefined the template compatibility type(0For adaptive,1For code adaptation,2for computer+mobile phone), whereasstatusindicates the usage status of the template(0is disabled,1indicating it is in use). It is worth noting that among all templates, only one set of templatesstatusThe value of1That is, only one template can be enabled at a time.

There are mainly two ways to organize template files in a directory: folder organization mode and flattened file organization mode. The folder organization mode usually places files of different types of pages (such as home page, detail page, list page, single page, etc.) in corresponding subdirectories, for exampleindex/index.html/{模型table}/detail.htmland. The flattened file organization pattern then places these files directly in the root directory of the template, through naming conventions (such asindex.html/{模型table}_detail.html)to distinguish. Regardless of the mode used, the system supports predefined custom template names, such as the default document template can be{模型table}/{文档id}.html, which can be automatically applied without any additional settings in the background.

On AnqiCMS backend management template

The AnqiCMS backend provides an intuitive interface to manage your templates.You can access the "Template Design" menu to access the "Website Template Management" feature, where you can view all installed templates and perform corresponding management operations.

Activate and switch template:The activation and switching of templates mainly involves modifying theirconfig.jsonin the filestatusfields to enable a template. When you want to enable a certain template, make sure that itsstatusis set to1while enabling other templates'statusis set to0. In the background template management interface, there are usually convenient buttons or options to perform this operation, the system will automatically handle it.config.jsonfor modification.

Customize a template for specific content:AnqiCMS is a major highlight with its powerful content model mechanism, which makes it extremely easy to apply dedicated templates for specific content.

  • Category template:In the 'Content Management' under the 'Document Category' settings, each category can be configured with a 'Category Template'. You can specify alist.htmltemplate file outside of the examplesdownload.htmlTo display the list of articles under this category. In addition, you can also choose whether to inherit the template settings of the subcategory.There is also a 'Document Template' option in the category settings, which can specify a detail page template for all documents under this category.
  • Document template:When publishing or editing a document, in addition to selecting the category, you can also find the 'Document Template' field in 'Other Parameters'. Here, you can specify a completely independent detail page template for the current document, for example, for a specific download article.download.html.
  • Single page template: For the 'Page Resources' under 'Single Page', the 'Single Page Template' field is also provided, allowing you to specify customized template files for single pages such as 'About Us', 'Contact Us', etc., for examplepage/about.html.

By these detailed settings, you can present a diverse visual style and functional layout for different parts of the website, greatly enhancing the professionalism and user experience of the website.

Template application in multi-site management

For operators with multiple site needs, the "Multi-site Management" feature of AnqiCMS is closely integrated with the template system.When adding a new site through Docker or Baota panel and other methods, the system will prompt you to 'select the template to use'.This means that each independent AnqiCMS site can choose and enable its own template, even different template types (adaptive, code adaptation, PC + mobile independent), thus easily achieving brand differentiation or meeting the needs of different business scenarios.

Template development and optimization hints

There are several key points to note when developing or modifying templates:

  • Uniform coding:All template files must use UTF-8 encoding to avoid page garbling issues.
  • Resource reference:The static resources referenced in the template should use the provided by the system.TemplateUrlLabel, for example<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">Ensure the correctness of the resource path, especially when there are changes in multi-site or deployment environments.
  • Code reuse:Fully utilize the AnqiCMS template engine'sinclude/extendsandmacroand other auxiliary tags.includeCan be used to introduce common code snippets (such as headers and footers);extendsUsed to implement template inheritance, build master pages, and overwrite specific areas;macroReusable code blocks can be defined to improve development efficiency and code neatness.
  • Static rules:When you use custom static rule in{filename}or{catname}When using variables, make sure that the custom URL you set for the document, category, or single page is unique across the entire site to avoid page conflicts.

By deeply understanding and flexibly applying the AnqiCMS template system, you will be able to create highly customized, feature-rich websites, effectively attract and retain users, and help you achieve success in content operation.


Frequently Asked Questions (FAQ)

1. How can I switch the template used by the current website in the AnqiCMS backend?Answer: You can find the 'Website Template Management' feature by accessing the 'Template Design' menu in the AnqiCMS backend.In this interface, it usually lists all the installed templates.You just need to select the template you want to activate, then click the corresponding 'Enable' or 'Set as Main Template' button, and the system will automatically update the configuration to switch to the template currently used by the website.Make sure to enable only one template at a time.

2. Can I use different template layouts for different pages on the website (such as news detail pages and product detail pages)?Certainly, it can be done. AnqiCMS provides powerful content models and custom template functions.You can specify different document templates for different categories (such as 'news categories' and 'product categories') under the 'Content Management' 'Document Category' settings.In addition, when publishing or editing a single document or a single page, you can also find the "Document Template" or "Single Page Template" field in their respective editing interfaces, to specify an independent template file for specific content, achieving finer-grained layout control.

3. What if the website front-end does not take effect immediately after I modify the template file?Answer: Generally speaking, AnqiCMS will take effect in real time on the modification of template files.If you find that the front-end page is not updated, please try to clear the browser cache first, as the browser may cache old page resources.If the problem still exists, you can try to access the 'Update Cache' feature on the AnqiCMS backend, manually clean the system cache to ensure that the latest template files are loaded.In very few cases, if your website uses a CDN, you also need to check and refresh the CDN cache.

Related articles

What are the basic conventions and file encoding requirements for AnqiCMS template creation?

As an experienced CMS website operation personnel, I know the importance of a high-quality, easy-to-maintain template for the successful operation of a website.The template is the facade of content display, which directly affects user experience and search engine optimization.In AnQiCMS, the creation of templates follows a series of basic conventions and strict file encoding requirements, which are designed to ensure the efficient operation of the system and the correct rendering of content.### Basic conventions for AnQiCMS template creation The core of AnQiCMS template creation lies in its concise and powerful conventions, which cover the file structure

2025-11-06

What mobile web modes does AnqiCMS support to adapt to different device visits?

As a website operator who is well-versed in the operation of Anqi CMS, I am fully aware of the importance of website adaptability to different devices in today's mobile internet era.The Anqi CMS fully considers this requirement, providing users with a variety of mobile website modes to ensure that the website content can be presented smoothly and efficiently on various devices.The AnQi CMS supports the following mainstream mobile website modes, allowing operators to flexibly choose the most suitable solution based on actual business needs and maintenance costs.First is the **adaptive mode**. In this mode, the website uses the same template and content

2025-11-06

How does the AnqiCMS paraphrasing feature improve the originality of articles?

In today's highly competitive online environment, content originality is a key factor in attracting users and improving search engine rankings (SEO).AnQiCMS (AnQiCMS) is a content management system designed specifically for content operation teams and small and medium-sized enterprises, deeply understanding this field.

2025-11-06

How to customize the backend domain in AnqiCMS and enhance backend security?

As an experienced CMS website operation personnel of a security company, I am well aware of the importance of the security of the content management system backend to website operation.A secure backend not only protects your data assets but also ensures the stable operation of the website and user trust.Aqj CMS is well-versed in this and introduced the feature of custom backend domain names in its v2.1.1 version, which is a key element in strengthening backend security.

2025-11-06

How to use common tags in AnqiCMS templates (such as `system`, `archiveList`)?

As an experienced security CMS website operator, I know that every link in content creation and management cannot be separated from a flexible and efficient template system.AnQi CMS with its simple design and powerful functions, provides us with great convenience.In template design, proficiently using various built-in tags is the key to building high-quality, user-friendly websites.Today, I will give you a detailed explanation of the two most commonly used and powerful tags in the AnqiCMS template: `system` and `archiveList`, and how they help us achieve a rich and diverse content display

2025-11-06

How to correctly use the Markdown editor on the AnqiCMS website and display mathematical formulas and flowcharts?

As a senior CMS website operation personnel of a well-known security company, I am well aware of the importance of content diversity and professionalism in attracting and retaining users.When dealing with technical, academic, or content that requires clear logical demonstration, integrating Markdown editor with mathematical formula and flowchart functions can undoubtedly greatly enhance the expressiveness of the content.The new version of Anqi CMS adds a Markdown editor feature, which is to meet such needs, making content creation more efficient and professional.

2025-11-06

How to add and manage documents in AnqiCMS, what recommended properties can be set?

As a senior CMS website operation person in a security enterprise, I know that content is the lifeline of the website, and an efficient content management system is the cornerstone of the success of the content strategy.AnqiCMS with its flexible and versatile features, provides us with a seamless experience from content creation to publication.Next, I will give a detailed introduction on how to add and manage documents in AnqiCMS, and delve into those recommended attributes that can greatly enhance the value of content.### Adding Documents: The Foundation for Building Rich Content Adding documents in AnqiCMS is an intuitive and powerful process

2025-11-06

What impact do document keyword management and custom URLs have on SEO ranking?

As an experienced AnQiCMS (AnQiCMS) website operator, I am well aware of the close relationship between content creation and website optimization.AnQi CMS is a product designed specifically for content management and SEO optimization, with built-in keyword management and custom URL features that are the core tools for improving a website's performance in search engines.I will elaborate in detail on the profound impact of these two functions on SEO rankings.### Keyword management in AnQi CMS has a significant impact on SEO ranking In the AnQi CMS ecosystem

2025-11-06