In AnQiCMS, whether the content can be presented correctly and elegantly to the user largely depends on the organization and naming conventions of the template files.Understand these basic conventions, which can help you design and manage website interfaces more efficiently, ensuring the accurate presentation of content.

The cornerstone of the template file:/templateTable of contents and.htmlsuffix

AnQiCMS has clear regulations for the placement of template files: all template files must be stored in the root directory of the website./templateIn the folder. This directory is the only entry point for AnQiCMS to find and load templates. At the same time, template files are uniformly used.htmlAs a suffix, this is not only the mark of the system recognizing the template, but also conforms to the general habits of front-end development.

When you create or edit a template file, you also need to pay special attention to the file encoding.AnQiCMS requires template files to be encoded in UTF-8.If the page is displayed in a different encoding format, it is very likely to appear garbled, which will affect the user experience.For users accustomed to editing in the Windows environment, it is necessary to select UTF-8 format when saving.

In addition, the static resources such as CSS stylesheets, JavaScript scripts, and images required by the template should not be placed directly in/templateIn the directory. AnQiCMS provides a special place for storing these static resources./public/static/Directory. Separating static resources from template files helps improve the loading efficiency and maintenance convenience of the website.

Flexible organization methods: folder mode and flat mode

AnQiCMS provides two main template organization modes to meet the needs of websites of different scales and complexities:

  1. Folder organization mode:This pattern categorizes templates by creating subfolders, making the structure clear and easy to manage large projects. For example, the homepage template may be locatedindex/index.html, and the article detail page template may be locatedarticle/detail.html, the product list page template is locatedproduct/list.html. Common code snippets for some pages, such as website headers (header), footers (footer), or sidebars (sidebar), are usually stored inpartial/In the catalog and pass throughincludeLabel at the required location for reference, to achieve code reuse. This hierarchical structure allows developers to quickly locate and modify specific function templates, greatly enhancing maintenance efficiency.

  2. Flattened file organization mode:For websites with relatively simple structures and a small number of pages, a flat model may be more convenient.In this mode, most template files are directly stored in the root directory of the template, and are distinguished by a naming convention for different types of pages.For example, the home page template might beindex.htmlArticle detail page template isarticle_detail.htmlProduct list page template isproduct_list.htmlThis pattern reduces the directory level, making the files clear at a glance, suitable for rapid development and lightweight maintenance.

No matter which mode you choose, the key is to maintain consistency and follow the naming conventions of AnQiCMS.Because the system will automatically match the content with the template according to these conventions, ensuring the correct display of the content.

Considerations for mobile-endmobile/Table of contents

With the popularization of mobile Internet, responsive design or independent mobile pages are becoming more and more important.AnQiCMS took this into consideration and provided good support for mobile templates.

If your website chooses to use the template type 'Code Adaptation' or 'Computer + Separate Mobile Site', AnQiCMS will look for a folder namedmobile/in your template folder. Thismobile/The internal structure and file naming rules of the directory are consistent with the main template directory (PC end). This means that if you have aarticle/detail.htmlUsed for PC end article details, then the corresponding mobile end article detail template should be placedmobile/article/detail.html. Thus, AnQiCMS can automatically load and display the corresponding template according to the type of device accessed, providing a ** browsing experience for users of different devices.

The template's 'ID':config.json

Every set of AnQiCMS template needs an 'ID'——which is under the template directoryconfig.jsonThe file. This file contains the basic information of the template, allowing AnQiCMS to identify and manage this template correctly.

config.jsonIt contains some important fields:

  • nameTemplate display name, convenient for you to select and identify the template in the background.
  • packageTemplate folder name, usually a combination of letters and numbers, serving as the unique identifier for the template.
  • versionThe version number of the template, convenient for tracking and updating.
  • template_typeThis is a key field that defines the type of the template. For example,0Represents an adaptive template (a set of templates that adapt to all devices),1Represents code adaptation (requires an independent mobile directory),2Represents an independent computer + mobile site.
  • status: Indicates the enabled status of the template,0is disabled,1In use. Only one template can be used in all templates.statusThe value of1The template is enabled.

Byconfig.json,AnQiCMS not only understands the basic properties of templates, but can also switch templates and adapt functions accordingly.

Intelligent matching: preset template name

AnQiCMS is another convenient feature as it intelligently recognizes certain pages.If you create a template file following the system's predefined naming rules, AnQiCMS can still automatically apply these templates even if it is not manually set in the background.This greatly simplifies the template configuration process.

Some common preset template names include:

  • Document Details Page: {模型table}/{文档id}.htmlor{模型table}/detail.htmlFor example,article/123.htmlIt will match the article with ID 123, whilearticle/detail.htmlIt will be the default detail page template for all articles.
  • Document List Page: {模型table}/list-{分类id}.htmlor{模型table}/list.htmlFor example,product/list-45.htmlIt will match the product category list with ID 45, whileproduct/list.htmlis the default list template for all product categories.
  • Single page detail page: page/{单页面id}.htmlorpage/detail.htmlFor example,page/about-us.htmlCan be used as the exclusive template for the "About Us" page.

This intelligent matching mechanism provides a certain flexibility. You can create customized template files for specific documents, categories, or single pages without changing the templates of other general pages.If you have a name calledabout.htmlThe single page template, just specify the template of this page in the single page management of the backgroundpage/about.htmland the system will automatically load it.


In summary, the template file naming and directory structure of AnQiCMS is the core of its content display mechanism. By placing all template files in a/templatedirectory and using.htmlFile extension and UTF-8 encoding can ensure that the system correctly identifies and parses. At the same time, choose the folder organization or flat organization mode according to the scale of the website, cooperate withmobile/Directory processing for mobile display, as well asconfig.jsonFile management template metadata, capable of achieving efficient template development and maintenance.The intelligent recognition function of the system for preset template names further enhances the convenience and flexibility of content matching with templates.Master these conventions, and your AnQiCMS website will be presented to visitors in the most ideal way.


Frequently Asked Questions (FAQ)

1. If my template file is not/templatein the directory, or the file extension is not.html, can AnQiCMS still display the content normally?You can not. AnQiCMS strictly requires that template files must be stored in/templatethe directory, and.htmlAs a file extension, otherwise the system will not be able to recognize and load these templates, which may cause the content to be displayed abnormally, even leading to page errors.

2. How does AnQiCMS decide which template to use for a specific page (such as an article or product detail page)?AnQiCMS will decide based on a set of priority rules.Firstly, it will check if a custom template is specified for the article, category, or single page in the background.If not, it will try to find a preset template file that matches the content model, category ID, or single page ID (such asarticle/detail.htmlorproduct/list-123.html)。Finally, if none of the above rules match, the system will fallback to the default generic template.

3. Can I use folder organization mode and flattened file organization mode at the same time in a template theme?In technical terms, you can mix these two modes under a template theme because AnQiCMS will look for files according to the agreed path. However, in order to maintain the consistency and maintainability of the template structure, as well as to avoid potential file naming conflicts or confusion, it is strongly recommended that you...