When using AnQiCMS for website construction and content management, understanding the naming conventions of its template files is crucial for customizing and optimizing the website's appearance.The Anqi CMS simplifies template management by providing a flexible and default recognition naming convention, allowing developers and operators to work more efficiently.

Firstly, all template files are统一使用.htmlAs a suffix, and placed centrally in the root directory of the website/templateIn the folder. While the styles, JavaScript scripts, images, and other static resources used in the template will be stored separately in/public/static/Directory. The Anqi CMS template engine syntax is similar to Django templates, which allows users familiar with this syntax to quickly get started.

The strength of AnQi CMS lies in its ability to intelligently recognize and automatically apply template files that conform to specific naming rules, without requiring additional configuration in the background.This greatly accelerates the development and deployment process. For document detail pages and list pages, there are several main default template file naming methods:

Default template file for the document detail page

The document detail page is the core page for displaying single content (such as articles, product introductions). Anqi CMS provides two default naming modes to meet different customization needs.

A precise match is one that is specific to a particular document ID:{模型table}/{文档id}.htmlHere,{模型table}represents the table name of the content model to which the document belongs (for example, if it is an article model, it might bearticleIf it is a product model, it may beproduct),while{文档id}This is the unique identifier of the document in the system. This means that if you want to design a unique detail page layout for a specific document (such as an article with ID 10), you can createarticle/10.htmlSuch a template file. When accessing this specific article, the system will try to load this exact matching template first.

Another is a general match for the entire content model:{模型table}/detail.html. If a specific document does not have a dedicated{文档id}.htmltemplate, or if you want to provide a unified page layout for all documents under a specific content model, you can create a nameddetail.htmlThe file, and place it in the corresponding content model (such asarticleorproduct) folder, formingarticle/detail.htmlorproduct/detail.html. So, all documents under this model will use this by default when accesseddetail.htmlTemplate.

The default template file for the document list page

The document list page is used to display multiple articles under a certain category, and also provides flexible naming methods.

One is an exact match for a specific category ID:{模型table}/list-{分类id}.html. Similar to the document detail page, here the{模型table}represents the table name of the content model, and{分类id}It is the unique ID of the document category. If you want to design a unique list page for a specific category (for example, a product category with ID 5), you can createproduct/list-5.htmlSuch a template. When accessing the list page of this specific category, the system will load this template first.

Another is a general match for the entire content model:{模型table}/list.htmlIf a list template for a specific category ID is not found, or if you want to provide a uniform layout for all list pages under a specific content model, you can create a namedlist.htmlThe file, and place it in the corresponding content model (such asarticleorproduct) folder, formingarticle/list.htmlorproduct/list.html. All category list pages under this model will use this by default when accessedlist.htmlTemplate.

Default template file for a single page (additional notes)

Although it is not a document detail or list page, understanding the naming rules of single-page templates can also help us better understand the template mechanism of Anqi CMS. Single pages, such as "About Us", "Contact Us", also have similar default names:

  • For an exact match of a specific single page ID:page/{单页面id}.html
  • For a general match of all single pages:page/detail.html

It should be noted that the aforementioned naming rules apply to both “folder organization mode” and “flattened file organization mode”. In the “folder organization mode”, template files are stored in their respective subdirectories according to the model and page type; while in the “flattened file organization mode”, the filenames will contain information about the model and page type (such as{模型table}_detail.htmlorpage_detail.htmlBoth of these modes follow the same priority and automatic recognition logic.

By these default naming conventions, we can quickly apply different designs to the document detail page and list page of the website without modifying the background configuration.Of course, AnQi CMS also provides the function to specify a custom template file for specific documents, categories, or single pages in the backend management interface, which provides additional flexibility for more detailed personalized needs.Understanding these naming rules will greatly enhance our efficiency in website customization and content operation on AnQi CMS.


Frequently Asked Questions (FAQ)

  1. Ask: If I createdarticle/detail-10.htmlandarticle/detail.htmlWhich template will the system prioritize to display the article with ID 10?Answer: The system will prioritize using more specific templates. In this case, it will prioritize choosingarticle/detail-10.htmlTo display the article with ID 10. It will fallback to the general template when the specific ID template cannot be found.article/detail.html.

  2. Question: Where should the table name of the document model be viewed?{模型table}Where should the table name of the document model be viewed?Answer: You can find the 'Content Model' settings in the 'Content Management' module of the Anqi CMS backend. Each content model will have a 'Model Table Name' or 'URL Alias' field, which is used in template naming.{模型table}Values, usually lowercase English words, such asarticle/productetc.

  3. Question: If my website has separate templates for mobile and PC, do these default filenames also apply to the mobile端?Yes, these default naming rules also apply to the mobile template. In the AnQi CMS template root directory/templateBelow, if there is onemobileThe subdirectory, so the mobile template files should be stored inmobilethe directory, and follow the same naming conventions. For example, the mobile article detail page template might bemobile/article/detail.html.