How to set up independent templates for specific documents, categories, or single pages to control their display styles?

Calendar 👁️ 68

In AnQiCMS, setting up independent templates for specific documents, categories, or single pages is a key feature for personalized content display on the website and improving user experience.This not only makes the website design more flexible, but also allows for precise style control for different types of content, thereby better meeting the brand positioning and content operation strategy.

Understanding the template mechanism of AnQiCMS

AnQiCMS provides two main ways to apply custom templates: one is that the system automatically identifies and loads templates based on file naming rules, and the other is to manually specify the template used for a particular content in the background management interface.Both of these methods give content great display freedom, you can choose the most suitable one according to your needs.

AnQiCMS template files are usually named with.htmlwith suffix, and stored uniformly in/templateIn the directory where you use the template theme folder. Template creation follows a syntax similar to the Django template engine, making it easy to get started and convenient for developers or operators to customize.

Configure independent templates for different types of content

1. Set up an independent template for a single page

A single page (such as "About Us",

  • Automatic recognition: AnQiCMS has a smart template recognition mechanism. If you create a named folder in the current template theme directory,page/{单页面ID}.htmlorpage/{单页面别名}.htmlThe file (for example, if your single page ID is 10, then the file name ispage/10.html; if your single page alias is set toabout-us, then the file name ispage/about-us.html),The system will automatically load this template when accessing the single page. This means that as long as the template file exists and the naming follows the rules, it will take effect without any additional settings.
  • Manually specified:When you want to have more precise control over a single page or when the file naming does not conform to the automatic recognition rules, you can specify it manually from the background. You canPage Resources-u003ePage ManagementEdit the corresponding single page. In the 'Other Parameters' area of the editing interface, find the Single page templateField. Here, you can fill in the template file name you want to use, for examplecustom-about.htmlPlease note that this file must exist in the root directory of the template theme you are using, or in a specified subdirectory, for examplepage/custom-about.html. Fill in after, this single page will display the specified template first.

2. Set an independent template for categories.

The uniformity of the style of the category page (such as the article list page, product list page) is crucial for user experience, but sometimes it is also necessary for individual categories to show different styles.

  • Automatic recognition (category list page):Similar to a single page, AnQiCMS can automatically load templates based on the category ID. If there is a folder named in your template theme directory named{模型table}/list-{分类ID}.htmlThe file (for example, the category list page under the article model with ID 1 can be namedarticle/list-1.html), the system will automatically apply this template.
  • Manually specify (category list page):You canContent Management-u003eDocument CategoryEdit the corresponding category. In the "Other Parameters" area of the category editing page, find the "category template" field. Here you can enter the name of the custom template file, for examplespecial-category-list.htmlThis template file is usually used to control the layout of the list page under the category.
    • It is worth mentioning that there is also a “Apply to subcategoryThe option. If you check this, all subcategories under this category (if they do not have their own category template set) will follow this template, which is very convenient for maintaining the uniformity of hierarchical content.
  • Specify a template for the documents under the category:In addition to the category list page, you can also find under the category level for this category.All documentsSet a default document template. In the "Other Parameters" area of the category editing page, find theDocument TemplateTemplate file name entered here, for examplespecial-article-detail.htmlIt will be the default display template for all documents under this category.This means that when a user accesses any document under this category, if the document itself does not specify a template independently, then the document template at this category level will be used.

3. Set an independent template for the document

For certain special articles, product detail pages, you may need them to have a completely unique display style to highlight their importance or characteristics.

  • Automatic recognition: The system also supports automatic recognition of document detail pages. If you create a file named under the current template theme directory{模型table}/{文档ID}.htmlThe file (for example, a document under the article model with ID 100 can be namedarticle/100.html), the system will automatically load this template.
  • Manually specified:This is the highest priority template setting method. You canContent Management-u003epublish/edit documentsoperate. In the "Other Parameters" area of the document editing interface, find theDocument TemplateField. Here you fill in the name of the template file you want to use, for examplefeatured-product.htmlOnce a separate template is specified for a document, it will override the document template set at the category level, ensuring that the document is presented in the most unique way possible.

Template file storage location and naming rules review

To better utilize these features, please remember the following key points:

  • Root directory:All custom template files should be placed in the current theme folder you are using (for example/template/default) inside.
  • Subdirectory:It is recommended to place template files of different content types in the corresponding subdirectories, such aspage/Used for single page,article/or{模型table}/for documents and categorization lists.
  • Automatically recognize naming format:
    • Single page:page/{单页面ID}.htmlorpage/{单页面别名}.html
    • Category list page:{模型table}/list-{分类ID}.html
    • Document Details Page:{模型table}/{文档ID}.html
  • Manually specify naming:You can freely name the template file (for examplecustom-template.html),Then fill in the template field with the corresponding file name in the background. If the template file is in a subdirectory, you need to include the subdirectory path, for examplepage/custom-template.html.

By flexibly using these independent template settings provided by AnQiCMS, you will be able to create a unique visual experience for every part of the website's content, not only making your website more attractive but also better conveying information and achieving more refined content operation goals.


Frequently Asked Questions (FAQ)

Q1: If a document meets both the automatic recognition template naming rules and is manually specified in the background, which one will AnQiCMS prioritize?A1: AnQiCMS will prioritize using the document, category, or single page you set in the backend management interfaceSpecify manuallyThe template. Manually set priorities are highest, they will override the automatically recognized templates, as well as the document templates inherited from the parent category.

Q2: Can I set a uniform template for all documents under a certain category without having to set each document individually?A2: Can do. You can find it in the 'Other Parameters' area when editing categories.Document TemplateThe field. Here you fill in a template filename, all documents in this category (unless the document itself specifies a template) will default to using this template for display.This is very effective for maintaining the style of documents for a specific topic or series.

Q3: If I specify a non-existent custom template file, will the website generate an error? Or how will it display?A3: If you specify a non-existent template file in the background, AnQiCMS will fail to load the template, which usually leads to page display errors or falling back to the system default template (if it exists and logic allows).Therefore, when specifying a custom template, please ensure that the template file has been uploaded and named correctly.

Related articles

What is the directory structure of AnQiCMS templates, and how to organize template files for efficient display?

Build and manage website templates in AnQiCMS, the first step is to understand its unique directory structure and file organization.This not only concerns the visual presentation of the website, but also affects the performance, maintainability, and future scalability of the website.A clear and reasonable template organization strategy can greatly improve the work of content operation and front-end development.### Overview of AnQiCMS Template System AnQiCMS uses a syntax similar to the Django template engine, with `.html` as the template file suffix, which allows developers familiar with this template language to get started quickly

2025-11-08

What are the basic conventions to follow when making AnQiCMS templates to ensure correct content display?

Build a website template in AnQiCMS, as if designing a beautiful appearance and a practical functional framework for the website.Ensure that the carefully designed content is accurately displayed to visitors, it is crucial to follow some basic template design conventions.These conventions can not only help you efficiently complete template development, but also ensure the stability of the website and the convenience of future maintenance. ### One, the organization and coding specifications of template files Firstly, AnQiCMS has clear requirements for the **location and naming** of template files. All template files should be written with `

2025-11-08

How does AnQiCMS improve website content loading speed and user display experience through static caching?

In today's fast-paced digital world, website loading speed directly affects the first impression and the time spent by users on the website.A fast-loading website not only enhances user experience but is also one of the key factors in search engine optimization (SEO).AnQiCMS deeply understands this point, and has built-in powerful static caching mechanisms, aiming to fundamentally improve your website's performance and user experience. ### Understanding Static Caching: The Secret Weapon of Website Acceleration Imagine that your website is a bustling café.Each time a customer orders coffee (visits a page)

2025-11-08

How does the scheduled release feature ensure that my content goes live and is visible to the public at a specific time?

As content creators or website operators, we know how important the rhythm of content publishing is.Maintain a stable update frequency, push the latest information during the peak period of user activity, and even accurately release for different time zone audiences. All of these are directly related to the exposure and interaction effect of the content.However, manual operation is not only time-consuming and labor-intensive, but also prone to errors, especially when frequent releases or cross-time zone operations are required.Fortunately, the timed publishing function of AnQiCMS (AnQiCMS) perfectly solves these problems, making content operation easy and efficient.Scheduling post

2025-11-08

How to use the `archiveList` tag in AnQiCMS templates to flexibly display document lists?

In AnQi CMS, when we need to dynamically display articles, products, or other document lists on the website, the `archiveList` tag is an indispensable core tool.It provides high flexibility and powerful features, whether you want to display the latest content, hot articles, products in specific categories, or even generate lists based on keyword search or custom filtering conditions, `archiveList` can easily handle it.### `archiveList` core functionality and basic usage `archiveList`

2025-11-08

How is the `archiveDetail` tag used to retrieve and display detailed content information for a single document?

In AnQi CMS, the `archiveDetail` tag is a very core and practical tool for template creation, mainly used to retrieve and display detailed content information of a single document.Whether it is a blog post, product details, news report, or any other page content that needs to be independently displayed, `archiveDetail` can help you flexibly extract and present it on the website's front-end page.### `archiveDetail` Tag Core Function Overview The purpose of this tag is to provide rich data support for a single document

2025-11-08

How to use `categoryList` and `categoryDetail` tags to build and display category navigation and details?

In website content management, category navigation and detail pages are the core paths for users to browse the website and obtain information, as well as an important basis for search engines to understand the website structure.A clear and intuitive classification system not only greatly enhances the user experience, but also effectively helps the website's SEO performance.For users of Anqi CMS, flexibly using the `categoryList` and `categoryDetail` template tags provided by the system can easily build powerful, beautiful, and practical classification navigation and detail display.--- ### One

2025-11-08

How do the `pageList` and `pageDetail` tags manage and display the single-page content of a website?

In website operation, single-page content (such as "About Us", "Contact Information", "Service Introduction", etc.) plays a crucial role.They are usually carriers that display the core information of a company, brand story, or specific service details.To efficiently manage and display these pages, AnQiCMS provides the `pageList` and `pageDetail` two core tags, making content organization and presentation both flexible and convenient.### Back-end management of single-page content In AnQiCMS back-end

2025-11-08