AutoCMS as an enterprise-level content management system developed with Go language, provides efficient and stable content management services while also granting users high levels of customization, especially in template design.When we want a specific page of the website to have a unique style, custom document templates become an indispensable tool.However, how to normatively name these template files so that the system can be more intelligent and efficient in identifying and applying them is a concern for many operators.Today, let's delve into the naming conventions recommended by the system when customizing document templates in Anqi CMS.

Firstly, let's talk about the basic conventions of the security CMS template files. All template files are named with.htmland stored uniformly in the system./templateThe directory. To maintain the cleanliness and maintainability of template files, the styles, JavaScript scripts, and images, etc., required by the template, are usually placed separately in/public/static/Directory.The template writing in Anke CMS adopts syntax similar to Django template engine, which allows developers familiar with this engine to quickly get started.At the same time, in order to ensure the correct display of content, the template files are uniformly encoded in UTF8 to avoid the occurrence of garbled characters.

The template organization of Anqi CMS is flexible and diverse, roughly divided into two modes: "folder organization mode" and "flattened file organization mode".No matter which mode you choose, it supports setting a generic template for different content types.{模型table}/detail.html(folder mode) or{模型table}_detail.html(Flat mode) such a general template. Similarly, the general template for the list page can be{模型table}/list.htmlor{模型table}_list.htmland the corresponding page detailpage/detail.htmlorpage_detail.htmlThese general templates are like 'default skin', and they are automatically called by the system if no more specific ones are specified.

However, the strength of Anqi CMS lies in the fact that it also provides a more detailed and intelligent template automatic application mechanism, which is the focus of our discussion today - the system recommended naming rules for custom document templates.When your template files strictly follow these naming rules, even if you do not manually specify a template for each document or category in the background, the system can automatically identify and apply it, greatly improving the efficiency of content operation.

Specifically, Anqi CMS provides the following recommended naming formats for different types of content:

  • Default custom template for document detail pages:The recommended naming format is{模型table}/{文档id}.html。 Here are{模型table}refers to the table name of the model you define in the background content model (usually in lowercase English, such asarticle/product), and{文档id}The number ID that is unique to the document in the system. For example, if you have a document of an article model, the ID is123,那么你可以创建一个名为article/123.htmltemplate file. When accessing the ID of123的文章时,system will prioritize loading this exclusive template. Similarly, for the product model with ID456product, it can be namedproduct/456.html.

  • default custom template for the document list page:The recommended naming format is{模型table}/list-{分类id}.htmlThe same applies, {模型table}represents the model table name. While{分类id}Then it is the unique digital ID of the document category.This means you can design a unique template for all document list pages under a specific category.10create a list template for the category, you can name itarticle/list-10.htmlWhen the user browses the list of this category, the system will automatically apply this template.

  • Default custom template for single-page detail pages:The recommended naming format ispage/{单页面id}.htmlFor independent single pages such as "About Us", "Contact Information", etc. on the website, you can create dedicated templates based on their ID. For example, if the ID of the "About Us" page is78English, then the template file can be namedpage/78.html.

It is worth noting that, in addition to the above ID-based automatic recognition rules, the Anqi CMS also provides flexibleCustom URL Alias NamingAbility. This means you can set a meaningful URL alias for documents, categories, or single pages (for example, setting the URL alias for the "About Us" single page toabout),Then, in the template design, directly createpage/about.htmlsuch template files. When editing a single page in the background, you can manually specify the use ofabout.htmlThis provides you with greater freedom, allowing the naming of template files to be clear and closely associated with the content theme.

In summary, the template naming rules of Anqi CMS take into account the convenience of automated recognition and the flexibility of manual fine control.By proficiently applying these naming conventions, operators can not only make the structure of the website template clearer and easier to manage, but also provide highly customized display effects for specific content without modifying the core code, thereby creating a more attractive and professional website.In actual operation, we recommend giving priority to the system-recommended ID-based naming rules to maximize the use of the automation features of AanQi CMS.For pages requiring special handling, the **practice** of website design is realized by combining custom URL aliases with manual template specification.


Common Questions (FAQ)

  1. Why does AnQi CMS recommend these specific naming conventions instead of allowing me to name freely?The AnQi CMS recommends specific naming conventions, mainly to achieve the "auto-matching" and "intelligent application" of templates. When template files are followed by{模型table}/{文档id}.htmlThis format naming enables the system to automatically detect and load the most matching template for the current content (document, category, or single page) during page rendering without the need for manual specification in the backend.This greatly simplifies the workload of template management, especially for websites with large content or those requiring frequent updates, which can significantly improve operational efficiency and maintenance convenience.

  2. If I have not created a recommendation naming template for a specific document or category, how will the system handle it?If the system cannot find a dedicated template that perfectly matches the ID of the content you are currently accessing (for example,article/123.htmlIt will try to find a more general template upwards. For example, it will try to loadarticle/detail.html(for the document detail page) orarticle/list.html(For the category list page).If these general templates do not exist, the system will ultimately fall back to using the default core rendering logic to display content, but at this time, the page's style and layout may not be the customized effect you expect.Therefore, to ensure the consistency and aesthetics of the website, it is recommended to prepare a set of generic detail page and list page templates for each model type at least.

  3. Can I name the template file using the custom URL alias of the document instead of the document ID?It can be done, Safe CMS provides this kind of flexibility. Edit documents, categories, or single