What are the recommended naming rules for the template file when customizing the document template?
AnQi CMS is an enterprise-level content management system developed with Go language as its core, providing efficient and stable content management services while also giving users a high degree of customization, especially in terms of template design.When we want a web page to have a unique and stylish design, a custom document template becomes an indispensable tool.However, how to name these template files in a standardized way 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 deeply into the naming conventions recommended by AnQi CMS when customizing document templates.
Firstly, let's talk about the basic conventions of the Anqi CMS template files. All template files are named with.htmlsuffix and stored uniformly in the system./templateUnder the directory. To maintain the cleanliness and maintainability of the template, the static resources required by the template, such as styles, JavaScript scripts, and images, are usually placed separately in/public/static/Under the directory. In terms of template writing, Anqi CMS adopts a syntax similar to the 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 file is uniformly encoded in UTF8 to avoid problems with garbled characters.
The template organization method of AnQi CMS is flexible and diverse, generally divided into two types: 'Folder Organization Mode' and 'Flat File Organization Mode'.No matter which mode you choose, it supports setting a generic template for different content types.For example, all document detail pages under a model can be used{模型table}/detail.html(Folder mode) or{模型table}_detail.html(Flat mode) such as general templates. Similarly, the general template for list pages can be{模型table}/list.htmlor{模型table}_list.html, and the corresponding single page detail page ispage/detail.htmlorpage_detail.htmlThese common templates are like 'default skins', which 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 file strictly follows 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 enhancing the efficiency of content operations.
In particular, AnQi CMS provides the following recommended naming formats for different types of content:
The default custom template for the document detail page:Recommended naming formats are:
{模型table}/{文档id}.htmlHere{模型table}refers to the model table name you define in the background content model (usually in lowercase English, such asarticle/productetc.), and{文档id}It is the unique numeric ID of the document in the system. For example, if you have a document of an article model, the ID is123, then you can create a namedarticle/123.htmlThe template file. When accessing this ID is123article, the system will load this exclusive template first. Similarly, for the product model under ID is456product can be namedproduct/456.html.The default custom template for the document list page:Recommended naming formats are:
{模型table}/list-{分类id}.htmlSimilarly,{模型table}represents the name of the model table. And{分类id}This is the unique numeric ID of the document's category. This means you can design a unique template for all document list pages under a specific category.For example, if you want to set the ID of the article model under10to create a list template for the category, you can name itarticle/list-10.html. When the user browses the list of this category, the system will automatically apply this template.The default custom template for the single-page detail page: Recommended naming formats are:
page/{单页面id}.html. For 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 is78Then the template file can be namedpage/78.html.
It is worth noting that in addition to the aforementioned ID-based automatic recognition rules, 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 theaboutCreate directly in the template designpage/about.htmlSuch template files. When editing a single page in the background, you can manually specify the use ofabout.htmlAs a template. This way, you have more freedom to name the template files clearly and closely related to 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 practice, we recommend prioritizing the system-recommended ID-based naming rules to maximize the use of the automated features of Anqicms.For pages requiring special handling, further complemented by the use of custom URL aliases combined with manually specified templates, to realize the practice of website design.
Frequently Asked Questions (FAQ)
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 "automated matching" and "intelligent application" of templates. When template files follow the
{模型table}/{文档id}.htmlWhen naming the format, the system can automatically detect and load the template that best matches the current content (document, category, or single page) without manually specifying it on the backend.This greatly simplifies the work of template management, especially for websites with large amounts of content or those that require frequent updates, which can significantly improve operational efficiency and maintenance convenience.If I have not created a recommended 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.html),it will try to look up a more general template. For example, it will try to loadarticle/detail.html(for the document detail page)orarticle/list.html(For category list pages). If these general templates do not exist, the system will eventually fall back to using the default core rendering logic to display content, but at this point, the page style and layout may not be the customized effect you expect.Therefore, in order 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.Can I name the template file with the document's custom URL alias instead of using the document ID?Can do, Anqi CMS provides this flexibility. Edit documents, categories, or single