How to set a custom template for the document detail page or category list page of AnQiCMS?

Calendar 👁️ 74

As an experienced website operations expert, I know that the flexibility and customizability of a content management system (CMS) are crucial for the long-term development of the website and the user experience.AnQiCMS (AnQiCMS) provides an excellent solution in this aspect with its powerful functions and ease of use.Today, let's delve into how to set up custom templates for your document detail page or category list page in AnQiCMS, making your website content display more personalized and professional.

In AnQiCMS, the flexibility of content display is one of its core advantages.Whether it is articles, products, or any other custom content model, AnQiCMS allows you to break away from the monotonous default layout, and create a unique page style according to your brand tone, content characteristics, or user needs.This not only helps to enhance the user experience, but also strengthens the brand image through differentiated display, and even has a positive impact on SEO optimization.

The Anqi CMS template system uses a syntax similar to the Django template engine, which is very easy to get started with for those familiar with web development. Even those who are not very familiar with technology can achieve template switching and configuration through intuitive backend operations. All template files are stored in a unified location./templateIn the corresponding template folder created under the root directory, while style sheets, JavaScript scripts, and images, etc., are stored independently./public/static/The catalog, this separation design makes the template structure clear and more convenient to maintain.

Next, we will explain in detail in two main ways how to set up a custom template for you.

Method 1: By naming conventions, let AnQiCMS automatically recognize and apply the template

AnQi CMS provides an intelligent and convenient mechanism that allows you to automatically identify and apply custom templates by using specific template file naming rules, without the need for additional settings in the background.This approach is particularly suitable for scenarios where unique layouts need to be applied to specific content or categories.

  1. Set an independent template for a single document detail page:When you want a specific article, product, or other type of document to have a completely independent detail page layout, you can follow the{模型table}/{文档id}.htmlFormat the name of your template file. For example, if your document model table name isarticle(article), and you want to set ID for123Set the article to customize the template, then you can create it in your template folder (such as/template/default/) under createarticle/123.htmlThis file. When the user accesses this article with ID 123, the system will automatically load and use it.article/123.htmlThe layout of the layout. This fine-grained control allows you to provide exclusive display for key content on the website.

  2. Set an independent template for a single category list page:Similarly, if you want a specific content category (such as a product series or a type of news) to have a unique list display page, you can follow{模型table}/list-{分类id}.htmlFormat the template file name. For example, forarticle(Article) The ID in the model is45category, you can createarticle/list-45.htmlThis file. In this way, when the user visits the article category page with ID 45, the system will enable this custom list template.

It is worth mentioning that, in addition to naming by ID, AnQi CMS also supports more general model-level templates, such as{模型table}/detail.htmlwhich are used for the default detail pages of all documents for the model, as well as{模型table}/list.htmlThis is the default list page for all categories of the model. These are basic templates that you can customize with more refined IDs or filenames.

Method two: Specify template files flexibly through the backend management interface

In addition to the naming conventions, Anqi CMS also gives you the ability to fine-tune control in the backend management interface.This method is more suitable for those who want to manually specify the template or do not want the template name to be strongly bound to the specific ID.

  1. Specify a template for a single document detail page:When editing documents, you can enterContent Management -> Document ManagementFind the corresponding document and click edit.In the 'Other Parameters' section of the document editing interface, you will find an input box named 'Document Template'.download.html(If you havearticlecreated adownload.htmlfile to display download-type documents). Make sure that the template file path you enter is relative to your current template folder (for example/template/default/article/The valid path. The system will prioritize the template specified here.

  2. Specify the template for the category list page:For the category list page, you can inContent management -> Document classificationEdit the corresponding category.In the 'Other Parameters' section of the category editing page, you will see a 'Category Template' field.custom_list.html. Similarly, this path is relative to the current template folder under the model directory (for example/template/default/article/The relative path. It is especially noteworthy that in the category settings, there is also a "Document Template" field. The purpose of this field is to, for the category underAll documentsSpecify a unified detail page template. For example, if you have a product category and you want all products in that category to use a template namedproduct_detail_standard.htmlThe template, you can fill in this field to avoid the trouble of setting it one by one.

Tips in practice

  • Template file storage:All custom templates should be placed in the theme you are currently using./template/{您的主题文件夹名}/Under the directory. For example, if you are using the default theme namedefault, and inarticlethe model, then the file path is usually/template/default/article/detail.htmlor/template/default/article/123.html.
  • Using existing tags:In the custom template, you can fully utilize the various template tags provided by AnQi CMS (such as{% archiveDetail %}Get document details,{% categoryDetail %}Get category details,{% archiveList %}Get document list and so on), these tags can help you easily call and display the content data of the background management.
  • File encoding:No matter which operating system you edit the template file under, please be sure to save it in UTF-8 encoding format to avoid garbled text on the page.
  • Test and debug:Before deploying to the production environment, it is strongly recommended that you thoroughly test your custom template in the development environment to ensure that all features work properly and the layout is displayed correctly.The Anqi CMS usually provides error tips when template parsing fails, which helps with debugging.

Through the above two methods, AnQiCMS provides the ability to customize templates from global defaults, model generics to fine-grained control of individual content, allowing you to flexibly create websites that meet your actual operational needs and have excellent brand image and user experience.


Frequently Asked Questions (FAQ)

  1. Q: Where should I place my custom template file so that AnQiCMS can recognize it?A: Your custom template file should be placed in/template/{您的主题文件夹名}/{模型table}/In the directory. For example, if you are using a nameddefaulttopic, and you want to set up a detail page template for the article (model table isarticle), then the file path might be/template/default/article/detail.htmlOr/template/default/article/123.html(If it is for a specific article with ID 123). For the category list page template, it is usually/template/default/article/list.htmlor/template/default/article/list-45.html.

  2. Q: Why does the document detail page still display the default style, even though I have only set the 'Category Template' for a certain category?A: "Category template" is mainly used to change the category'slist pagedisplay style. If you want to display the category underDocument detail pageAlso use a specific template, you need to find the "Document Template" field on the edit page of this category, and fill in the filename of the template you want to use on the document detail page.These are two different settings that control the list page and the detail page of the documents below.

  3. **Q: If I created a template file with a specific ID (such asarticle/123.html), as well as in the background document editing page's

Related articles

How does the AnQiCMS template support adaptive, code adaptation, and PC+mobile mode?

## AnQiCMS template: How to ride the multi-end content display with wisdom and flexibility?In today's fast-paced digital world, it is common for users to access websites through various devices.As experienced website operators, we know that whether a website can provide a smooth and high-quality experience on PCs, tablets, mobile phones, and other terminals is directly related to user retention and business conversion.

2025-11-07

How to define an AnQiCMS template configuration file (config.)?

As an experienced website operations expert, I fully understand the importance of a flexible and powerful content management system for enterprises.AnQiCMS is an excellent platform committed to providing efficient and customizable solutions.In the template ecosystem of AnQiCMS, a seemingly insignificant but powerful file - `config.`, plays a crucial role.It not only defines the basic attributes of the template, but also profoundly affects the behavior and performance of the template in the system.

2025-11-07

Where should the AnQiCMS template files be placed?

## Unveiling the Home of AnQiCMS Templates: Clear Guidance Helps You Customize Easily As an experienced website operations expert, I am well aware of the importance of a flexible and efficient content management system for businesses.AnQiCMS is an excellent platform developed based on the Go language, which not only wins the favor of many users with its high performance and high concurrency features, but also provides great convenience in customization.For operators and developers who want to fully utilize their customization potential and build personalized websites, clearly defining the storage directory of AnQiCMS template files is the first step towards success.

2025-11-07

How to generate random text for testing in the AnQiCMS template?

As an experienced website operations expert, I am well aware that during the website development and content testing stage, it is often difficult to cook without the necessary ingredients - lacking real content to fill the page, in order to verify design, layout and function.Especially for operators and developers who use powerful and flexible content management systems like AnQiCMS (AnQiCMS), efficiently simulating content is the key to improving work efficiency.

2025-11-07

How does the AnQiCMS template handle the escaping and unescaping of HTML content?

As an experienced website operations expert, I am well aware of the subtle balance between content safety and flexible display.In AnQiCMS such an efficient and secure content management system, understanding how its templates handle the escaping and unescaping of HTML content is crucial for building both aesthetically pleasing and secure user experiences.AnQiCMS is developed based on Go language, its template engine inherits many safety design concepts of modern web frameworks when processing HTML, including automatic escaping of HTML content.

2025-11-07

How to extract a specified part of a string or list in the AnQiCMS template?

In the daily operation of Anqi CMS, we often encounter scenarios where we need to display content in a refined manner.How to flexibly extract the part we want from a string or list, whether it is an article summary, product parameter list, or a user comment excerpt, is the key to improving user experience and page cleanliness.As an experienced website operation expert, I deeply understand the strength and flexibility of AnQiCMS based on Go language and Django template engine. Today, let's delve into how to accurately extract the specified part of a string or list in the AnQiCMS template.###

2025-11-07

How to implement string content replacement in AnQiCMS template?

As an experienced website operations expert, I know that flexibility and efficiency are the key to success in daily content management.How to quickly and accurately adjust the string content on the page in terms of content display, whether it is for SEO optimization, brand consistency, or to meet the ever-changing market needs, it is a core skill we must master.Today, let's delve deeply into how the AnQiCMS template cleverly implements the replacement function of string content, empowering your content operation.

2025-11-07

How to get the current website's system configuration information in AnQiCMS template (such as website name, Logo)?

As an experienced website operations expert, I am happy to discuss with you how to efficiently and flexibly obtain the current system configuration information of the website in AnQiCMS templates.This is not only the foundation of template development, but also the key to ensuring the consistency and maintainability of website information.AnQiCMS is an enterprise-level content management system developed based on the Go language, its concise and efficient design philosophy is also reflected in the use of template tags, making the call of technical information in the template layer extremely intuitive.### Cleverly utilize the `system` tag

2025-11-07