How does AnQiCMS automatically apply the display style of a specific category or page through the default custom template name?

Calendar 👁️ 67

In the daily use of AnQiCMS (AnQiCMS), the flexibility of templates is one of the key factors in improving content operation efficiency.For many website administrators, how to make specific content - whether it is an article, a product, a category page, or an independent single page - have a unique display style while avoiding cumbersome repetitive configuration is a common need.AnQi CMS solves this problem well through a clever default custom template naming mechanism, allowing content operations and front-end design to collaborate efficiently.

AnQiCMS template management basics

The AnQiCMS template system is developed based on Go language, using.htmlfiles as templates, and stored in a unified manner./templateUnder the directory. Its syntax is similar to the Django template engine, using double braces{{变量}}To output data, using single braces and the percent sign{% 控制结构 %}To implement logical control. This design makes template development intuitive and easy to learn.The system also supports adaptive, code adaptation, and various template types such as PC+mobile independent sites, providing a solid foundation for content display on different devices and scenarios.

Fine-grained control: The magic of the default custom template name

One of the most remarkable features of AnQiCMS is that it can automatically identify and apply templates based on specific naming rules.This means that for some pages that require personalized display, we do not need to manually select a template in the background. Just create a template file according to the agreed format, and the system can automatically match and apply it.This 'configuration by convention' design greatly simplifies the workflow, especially suitable for websites with large content volume and high customization requirements.

In particular, Anqi CMS supports several important default custom template names:

  • Document detail page (article/product)If you want a unique detail page layout for a specific article or product, you can create an HTML file named after the document ID in the folder of its model. The naming format is:{模型table}/{文档id}.htmlFor example, if there is a document of an article model with an ID of123and the table name of the article model isarticlethen you can create a filearticle/123.html. When a user accesses this ID of the article,123the article, AnQiCMS will automatically load and usearticle/123.htmlas its detail page template.
  • Category list pageSometimes, we may want a specific category (such as "Latest News" or "Special Offers") to have a unique display style on its list page.AnQiCMS allows you to create a dedicated list template for a specified category ID.Naming format is:{模型table}/list-{分类id}.htmlFor example, if your product model table name isproductand you want the ID to be5The product category displays different list styles, you can create a fileproduct/list-5.html. When the user visits the product category ID of5the page, the system will automatically enable this custom template.
  • a single page detail pageFor pages such as "About Us" and "Contact Information", personalized design is also important.AnQiCMS also provides a default template mechanism based on ID for single-page.Naming format is:page/{单页面id}.htmlFor example, if your "About Us" page ID is7you can create a filepage/7.html. AnQiCMS will prioritize and apply when rendering this single page.page/7.html.

Flexible hierarchy and priority

AnQiCMS follows a clear priority rule in template selection, ensuring both automation and the highest degree of customization:

  1. The template is manually specified in the backgroundThis is the highest priority. If you specify a template file when editing documents, categories, or single pages in the background (for example, in the "Document Template" or "Category Template" fields, fill inspecial-download.html), then the system will always use this specified template, regardless of whether there is a template that matches the default naming rules.
  2. Default ID Naming Template: Next is the one mentioned above, according to{模型table}/{文档id}.html/{模型table}/list-{分类id}.htmlorpage/{单页面id}.htmlThis format-named template. If it exists and the background has not manually specified a template, the system will automatically apply it.
  3. General templateIf neither of the above two templates exist, AnQiCMS will fall back to a more general template. For example, for all article detail pages, it will look for{模型table}/detail.html(such asarticle/detail.html);for all category list pages, it will search{模型table}/list.html(such asarticle/list.html);for all single pages, it will searchpage/detail.html.

This hierarchical design allows website managers to flexibly choose between using a general template, customizing a template for a specific ID, or explicitly specifying a dedicated template through the backend.

Empower website operation: the balance of efficiency and customization

The default custom template naming mechanism of AnQiCMS brings significant advantages to website operation:

  • Improve efficiencyFor scenarios where only a small number of contents require special design among a large amount, there is no need to frequently enter the background to select templates, just create a file.
  • Refined customizationAllow each key content or page of the website to be visually and functionally customized at the pixel level without interfering with each other.
  • simplify managementThe template file naming follows a regular pattern, which allows front-end developers and content operators to more clearly understand the purpose and relevance of the template, reducing maintenance costs.
  • optimize user experience:Provide a more fitting display method for content of different types or importance, indirectly improving user experience and conversion rate.

In summary, AnQiCMS combines smart default naming conventions with flexible backend configurations to provide users with an efficient and highly customizable content management solution, allowing website operators to focus more on the content itself rather than on the繁琐 technical details.


Frequently Asked Questions (FAQ)

Q1: If a category or document has both a default naming template (such asarticle/list-5.html) and a manually specified template in the background, which one will AnQiCMS prioritize?

A1:In AnQiCMS, the template manually specified in the background has the highest priority.If a category, document, or single page explicitly specifies the template file to be used in the background editing interface, the system will load and apply this manually specified template unconditionally, without searching for or using any templates that match the default naming rules.This design ensures that operations personnel have absolute control over a specific page.

Q2: The default custom template naming rule includes{模型table}What does that mean? Where can I find this name?

A2: {模型table}It refers to the table name of the content model in the database, as well as the identifier of the content model in the template system. AnQiCMS built-in "article model" and "product model", their model table names are usuallyarticleandproduct(The specific name can be viewed or customized in the background "Content Management" -> "Content Model").If you create other custom content models, the model table name also needs to follow this rule.For example, a custom model named "news" may have its table name set tonews.

Q3: In addition to naming templates by ID, can I set a generic default template for all articles or all categories in AnQiCMS?

A3:Yes, AnQiCMS supports setting common templates for all articles (or all documents under a specific model) and all categories. These common templates are usually named{模型table}/detail.htmlAnd it is used for all document detail pages{模型table}/list.htmlAnd it is used for all category list pages. For example,article/detail.htmlAnd it will serve as the general detail page template for all articles.product/list.htmlIt will serve as the common list page template for all product categories. These common templates have a lower priority than manually specified templates and default templates named by ID.

Related articles

How to implement separate mobile content display and adaptation in the AnQiCMS `mobile` template directory?

In today's mobile internet era, the mobile experience of a website has become an important standard for measuring its professionalism and user-friendliness.With the popularity of smartphones and tablet devices, there is an increasing demand for users to access website content smoothly on various screen sizes.AnQiCMS (AnQi CMS) deeply understands this trend and provides flexible and diverse mobile adaptation solutions, among which the design of the `mobile` template directory is the core secret to creating a dedicated mobile experience.###

2025-11-08

The UTF-8 encoding requirements of AnQiCMS template, how to ensure the normal display of multilingual content (such as Chinese)?

AnQiCMS (AnQiCMS) is a system focused on providing an efficient and customizable content management solution, with its powerful multilingual support function, it provides convenience for expanding the global market of the website.When using AnQiCMS to build a website containing Chinese or other non-ASCII character content, ensuring that these contents are displayed normally and avoiding garbled text is a fundamental and critical step.This is particularly important for the UTF-8 encoding requirement of the template file.The importance of UTF-8 encoding in template files Anqi CMS when handling template files

2025-11-08

How to standardize the use of variables and control tags in AnQiCMS templates to ensure the correct display of content?

In AnQiCMS (AnQiCMS), the template is the core of website content display.Whether it is to build a corporate website or operate a content-rich blog, the correct display of content is inseparable from the standardized use of variables and control tags in the template.Mastering these basic knowledge can not only help us flexibly customize the website interface, but also effectively avoid potential display errors, ensuring the stable and efficient operation of the website.The template syntax design of Anqi CMS draws inspiration from the Django template engine, its core lies in distinguishing variable output and logical control.Variables are usually enclosed in curly braces

2025-11-08

What is the impact of the `.html` suffix and `/template` directory structure of AnQiCMS templates on content display conventions?

In AnQiCMS, the organization and naming conventions of template files play a decisive role in the final presentation of website content.Understanding these conventions allows us to control the visual and functional presentation of the website more efficiently and flexibly. ### The "home" of the template file: `/template` directory and `.html` suffix When we start working on the template design of AnQiCMS, we first come across the `/template` directory under the root directory.This is the unified storage place for all website templates. This means that no matter how many sets of themes we create

2025-11-08

How does the `template_type` field in `config.` control the overall display mode of the AnQiCMS website?

In the AnQiCMS world, each template has a configuration file like an ID card - `config.`.It not only records the basic information of the template, but also carries a crucial setting, that is, how to determine the presentation of your website on different devices.This setting is the `template_type` field.### Explore `config.`: The 'manifesto' of the template When creating or selecting a template for an AnQiCMS website

2025-11-08

How to achieve consistent content display in the `bash.html` and `partial/` public code files of the AnQiCMS template?

In website operation, maintaining consistency in content display is the key to improving user experience, strengthening brand image, and simplifying maintenance work.AnQiCMS (AnQiCMS) provides a powerful mechanism in template design, through the `bash.html` file and `partial/` directory, etc., public code structure, helps operators easily achieve the unified and efficient management of the entire site content display.Imagine your website as a meticulously constructed house.To ensure the overall beauty and functionality of the house, we will not redesign the doors and windows or the roof in every room. Instead,

2025-11-08

How to specify a specific display template for the homepage, detail page, list page, etc. of the AnQiCMS website?

When building a website, we often need to assign unique appearances and functions to different page types, such as the grand layout of the homepage, the immersive reading experience of the article detail page, or the filtering and display of the product list page.AnQiCMS provides a flexible mechanism that allows users to easily specify and manage display templates for each page of the website.This has greatly enhanced the customization of the website, as well as greatly optimized the user experience and content presentation efficiency. The template files of AnQiCMS website are uniformly stored in the `/template` directory. Usually

2025-11-08

How does AnQiCMS's flat file organization pattern simplify template management and optimize the content display process?

In website operation, template management is a key link that balances efficiency and experience.A well-designed, easy-to-maintain template system that can greatly enhance the speed of website content publishing and the flexibility of page updates.AnQiCMS provides unique solutions in this field, especially its 'flat file organization mode', which brings practical convenience to users in simplifying template management and optimizing the content display process.### Say goodbye to layered nesting: The charm of AnQiCMS flat file organization In many traditional content management systems, template files are often buried deep in a multi-level directory structure

2025-11-08