When building and managing websites with AnQiCMS, understanding the naming conventions of its template files is crucial for customizing and optimizing the website appearance.The Anqi CMS provides a flexible and default recognition-capable naming convention to simplify template management, allowing website developers and operators to work more efficiently.
Firstly, all template files are unified using.htmlAs a suffix, and stored in the root directory of the website/templateIn the folder. The styles, JavaScript scripts, images, and other static resources used in the template will be stored separately./public/static/Catalog. The template engine syntax of AnQi CMS 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 any additional configuration in the background.This greatly accelerates the development and deployment process.
The default template file for the document details 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.
One is an exact match for a specific document ID:{模型table}/{文档id}.html
Here,{模型table}it represents the table name of the content model to which the document belongs (for example, if it is an article model,articleIf 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.htmlThis template file. When accessing this specific article, the system will first try to load this exact match template.
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 details 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 folder (such asarticleorproduct) under the folder, formingarticle/detail.htmlorproduct/detail.html. All documents under this model will default to using thisdetail.htmltemplates.
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,{模型table}represents the table name of the content model,{分类id}This 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.htmlThis 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 no list template for a specific category ID is found, or if you want to provide a uniform layout for all list pages under a particular content model, you can create a template namedlist.htmlThe file, and place it in the corresponding content model folder (such asarticleorproduct) under the folder, formingarticle/list.htmlorproduct/list.htmlThe category list page under this model will default to using thislist.htmltemplates.
Default template file for single page (supplementary explanation)
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” and “Contact Us”, also have similar default names:
- Exact match for a specific single-page ID:
page/{单页面id}.html - General match for all single pages:
page/detail.html
It should be noted that the above naming convention applies to both the "folder organization mode" and the "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 file names will contain information about the model and page type (for example,{模型table}_detail.htmlorpage_detail.html)。These two modes follow the same priority and automatic recognition logic.
Through these default naming conventions, we can quickly apply different designs to the document detail page and list page of the website without modifying the backend configuration.Of course, AnQi CMS also provides the function to specify a custom template file for a specific document, category, or single page in the background 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 the Anqi CMS.
Common Questions (FAQ)
Question: If I created
article/detail-10.htmlandarticle/detail.html,which template will the system prioritize to display the article with ID 10?答:The system will prioritize the use of more specific templates. In this case, it will prioritize choosingarticle/detail-10.htmlShow the article with ID 10. The default template is used when the template for a specific ID is not found.article/detail.html.Q: Where should I check the table name of the document model?
{模型table}) Where should it be checked?答: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, for examplearticle/productetc.Question: If my website has separate templates for mobile and PC, do these default filenames also apply to the mobile version?答:Yes, these default naming rules also apply to mobile templates. In the template root directory of Anqi CMS
/templatethere is onemobileSubdirectory, so the mobile template files should be stored inmobiledirectory, and follow the same naming conventions. For example, the mobile article detail page template may bemobile/article/detail.html.