What are the recommended naming rules for the template file when customizing the document template?

Calendar 👁️ 86

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)

  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 "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.

  2. 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 examplearticle/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.

  3. 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

Related articles

Where is the default storage location for the executable files of the AnQiCMS project?

AnQi CMS is an efficient and customizable enterprise-level content management system, with its core being a lightweight and powerful executable file.For any website operator, it is crucial to know the location of this 'heart', as it not only concerns daily maintenance and management, but also affects the stable operation and fault troubleshooting of the system.Where is the executable file of the project carrying all the functions of AnQi CMS usually stored?Let's uncover this mystery.

2025-11-06

What is the usual access path (URL) for the AnQiCMS backend? Can it be customized?

As an experienced website operations expert, I am well aware of the importance of the security and convenience of the background management entry for website operations.Understanding the backend access path settings and customization capabilities of AnQiCMS, an efficient and secure content management system, is an indispensable part of our daily work.Today, let us delve into the mysteries of the AnQiCMS backend access path together.

2025-11-06

Under the multi-site management mode, how are the cache and independent directories of each site named?

As an experienced website operations expert, I have accumulated rich experience in managing and optimizing various websites, especially with a deep understanding of AnQiCMS (AnQiCMS) as an efficient and stable content management system.Multi-site management is a powerful feature of AnQiCMS, allowing users to easily operate multiple independent websites under a single system.However, under such a model, many operators may be curious: How is the cache and data directory of each site independently managed by the system, and how are they named?Today, let's delve deeply into this issue.

2025-11-06

How to find and edit the template folder being used by the current site in AnQiCMS?

As an experienced website operations expert, I know that mastering the positioning and editing methods of templates like AnQiCMS, which is a flexible and efficient content management system, is a key step to achieving website personalization, enhancing user experience, and optimizing SEO.AnQiCMS with its lightweight and high-performance Go language provides us with a solid foundation, and its powerful template customization capabilities give content operators unlimited possibilities.Today, let's delve into how to accurately find and edit the template folder currently in use on the AnQiCMS website

2025-11-06

How can you determine which category list template file is being used on the current page?

As an experienced website operations expert, I know how important it is to understand the underlying logic of the page when managing the content system.Especially when it comes to website customization, feature expansion, or daily maintenance, quickly locating the template file in use can greatly improve efficiency.Today, let's delve into how to accurately determine which category list template file is being used on the current page in AnQiCMS (AnQiCMS).

2025-11-06

Where should the AnQiCMS single-page custom template files be stored?

In the daily operation of AnQiCMS (AnQiCMS), we often need to customize the website pages to meet specific design or functional requirements.A single page, such as 'About Us', 'Contact Us', etc., often carries unique brand information of the company, and therefore, configuring a custom template is a common need for website operators.Where should these single-page template files that carry creativity and customization be stored in the Anqi CMS directory?Today, let's delve deeply into this issue. ###

2025-11-06

How should mobile template files be organized and stored when making a mobile phone template?

As an experienced website operations expert, I know how important it is to have a good mobile website experience in today's mobile internet age.Users are accustomed to browsing content on various mobile devices. If your website does not display well on mobile phones, it will not only lose users but will also affect the search engine rankings.AnQiCMS (AnQiCMS) is an efficient and customizable content management system that also provides clear and flexible solutions for mobile template design.Today, let's delve into it in detail when making mobile templates with Anqi CMS

2025-11-06

What is the actual file path represented by variables like `{filename}` or `{catname}` in static rules?

## Unveiling the 'mysterious code' in AnQi CMS static rules: the truth about `{filename}` and `{catname}` As an experienced website operations expert, I am well aware that a friendly and efficient URL structure is crucial for a website's search engine optimization (SEO) and user experience.AnQiCMS (AnQiCMS) provides strong support in this aspect, especially its flexible static rule management function.However, when configuring these rules

2025-11-06