How to set a custom template for a specific document category and control whether subcategories inherit the template?

Calendar 👁️ 52

As a professional deeply familiar with the operation of Anqi CMS, I know the importance of content presentation in attracting and retaining users.The flexibility of AnQi CMS in content management, especially in template customization, provides us with a great degree of freedom, ensuring that every part of the content can be displayed in the most fitting way according to its characteristics.Today, I will elaborate on how to set up a custom template for a specific document category, and flexibly control whether the sub-categories inherit the template, thereby helping you create a more personalized and professional website.

Why do you need a custom category template?

In website operation, documents of different types often require different display layouts and styles.For example, a "news information" category may require a concise list of articles, highlighting the title and publication time;And a 'product case' category may need to display product images, feature summaries, etc., with a richer layout.The AnQi CMS custom category template feature is designed to meet such refined operation needs.It allows us to specify exclusive template files for specific categories, breaking the limitations of a single layout, improving user experience, even assisting SEO, and highlighting content points better through a unique page structure.

Set a custom template for a specific category

To apply custom templates to your documents, you need to first enter the Anqi CMS backend management interface.

First, please navigate to the "Content Management" section, and then click "Document Category".Here, you will see the list of all created categories. Select the target category you want to set a custom template for, and click the 'Edit' button next to it.

After entering the category editing page, please scroll down the page to find the "Other Parameters" section and expand it.You will see an input box named "Category Template" here.This input box is where you specify the custom template file.

Here, you need to enter the name of the template file you have designed. For example, if you have designed a list template for a category nameddownload.htmlyou can directly enter it here.download.html. The system will base on the content model of the category you have selected (such as "article model" or "product model"), in the corresponding model directory under your current theme template folder (such astemplate/your_theme_name/article/ortemplate/your_theme_name/product/Search and apply this custom template.

Make sure the template file you entered actually exists in your theme template directory.If the system cannot find the corresponding template file, the category page may not display normally, affecting user access.To avoid such problems, it is recommended to save and access the front desk page immediately after filling in.

Control the template inheritance behavior of subcategories

Below the 'Category Template' input box, you will see an option named 'Apply to Subcategories'.This option gives you great flexibility to decide the application scope of the custom template in the hierarchical structure.

By default, the Anqi CMS category template isNot inheritedThis applies to subcategories. This means that if you set a custom template for a parent category, its subcategories will continue to use their own template settings (which may be the default template or a custom template specified by each one).This default behavior is suitable for those scenarios where the content of parent-child categories is quite different and requires independent layouts.

However, if you want the custom template of a parent category to be applied to all its child categories, thus maintaining visual and functional consistency throughout the entire category hierarchy, you can set the 'Apply to child categories' option toInheritanceOnce inheritance is enabled, regardless of whether the child category has its own template settings, it will uniformly adopt the custom template specified by the parent category.This is very useful for cases that need to maintain strong brand consistency or a highly unified structure for sub-category content, which can greatly reduce the workload of repeated settings.

In actual operation, you need to decide whether to enable inheritance based on the overall design and content planning of the website.For example, if you have a 'download center' parent category and all its subcategories (such as 'software download', 'document download') share the same download list layout, enabling inheritance will be a wise choice.Conversely, if the subcategories have different focuses, such as 'News Reporting' and 'Special Research' which belong to the 'Articles' parent category, but have significantly different page layouts, then the default non-inheritance state should be maintained.

The practice of template file naming and storage

The default storage location of AnqiCMS template files:/templateUnder the root directory, each theme has its own folder, for example/template/your_theme_name/. Within the theme folder, you can create subdirectories according to the content model, such asarticle//product/,to better organize the template file.

For the category list page, the system will default to searching for{模型table}/list.htmlfile. When you enter a custom template name in the category settings, for exampledownload.htmlThe system will first look for the template path corresponding to the current modeldownload.html(such astemplate/your_theme_name/article/download.htmlYou can also use more descriptive filenames, for examplelist-download-center.htmlTo avoid confusion and improve maintainability.

By understanding and mastering the classification template customization and inheritance control features of Anqi CMS, you can manage the content presentation of your website more flexibly, providing your readers with a better and more personalized browsing experience.

Frequently Asked Questions (FAQ)

Q1: I have set a custom template for the category, but the front-end page shows an exception, how should I investigate?

A1:First, please confirm that the template filename you have entered in the classification template field is correct, and that the file indeed exists in the corresponding model subdirectory under the current theme template directory (for exampletemplate/your_theme_name/article/your_template_name.htmlIn addition, check for syntax errors in the template file content. Anqi CMS is based on the Django template engine, which has strict syntax. Even minor errors can cause the page to fail to parse.If the file path and content are correct, try clearing the website cache and check for error messages in the browser console.

Q2: In addition to the category list page, can I set a custom template for a single document or product?

A2:Yes, AnQi CMS supports setting custom templates for individual documents or products.When editing a document or product, you will see a "document template" or a similarly named field.Enter the template file name you designed, and the system will prioritize using this file to display the details page of this specific document.This is similar to the way the classification template is set up, providing finer control over content display.

Q3: Can I enable a different template for a specific child category if my parent category has enabled template inheritance?

A3:When the 'Apply to child categories' setting of the parent category is set to 'Inherit', child categories will be forced to use the parent category template.This means that you cannot directly override this inheritance through the "classification template" field of the subcategory.To meet your needs, you need to disable the template inheritance feature of the parent category and then set up a template separately for each child category that requires a custom template.Or, you can use logical judgment inside the parent category template (for example{% if category.Id == specific_subcategory_id %}To render different content blocks or include different sub-templates for specific subcategories.

Related articles

How does AnQi CMS support custom document category URL aliases, and what are the naming rules?

As an experienced CMS website operations personnel in a well-known security company, I am well aware that a flexible and search engine-friendly URL structure is crucial for the success of the website.AanQi CMS provides strong support in this aspect, especially for the custom URL alias feature for document classification, which greatly improves the website's SEO performance and user experience. ### Support and Function of Custom Document Category URL Aliases Anqi CMS, as an enterprise-level content management system developed in Go language, took SEO friendliness into account from the very beginning of its design.Among, the article

2025-11-06

How to set the SEO title and keywords of document classification to improve search engine visibility?

As an experienced security CMS website operator, I know that every detail can affect the website's performance in search engines.Content creation and optimization is my core responsibility, and the SEO settings of document classification are the key to improving search engine visibility, attracting target users, and ultimately促成 conversion.AnQiCMS provides many conveniences in terms of SEO, through reasonable configuration, we can fully utilize these features.

2025-11-06

How to add a lower-level subcategory for document classification and manage its hierarchical relationship?

In AnQi CMS, efficient content categorization is not only the cornerstone of organizing website information, but also the key to improving user experience and search engine friendliness.As a website operator who is deeply familiar with the operation of Anqi CMS, I know that a logical and hierarchical classification system is crucial for content management and distribution.This article will detail how to add a lower-level subcategory for existing categories in Anqi CMS and effectively manage its hierarchy.### Build a clear content classification system In the Anqi CMS backend management interface, the content classification module is the core area for building the website information architecture

2025-11-06

Can the content model of a document category be modified after its creation?

As a senior CMS website operation personnel in the security industry, I know that understanding data structures and content classification is crucial in content management.Regarding whether the content model of a document category can be modified after its creation, it is indeed a frequently questioned focus in daily operation.In the design philosophy of Anqi CMS, the association established between the content model and document classification is the core of system content organization.Once the document category is created and the content model it belongs to is specified, this association is fixed and cannot be directly modified.Specifically

2025-11-06

Does the Anqi CMS document classification support uploading Banner images and thumbnails? How to call them on the front end?

As a website operator deeply familiar with the essence of Anqi CMS content management, I know the importance of image content in attracting and retaining users.Regarding your concern about whether Anqi CMS supports uploading Banner images and thumbnails for document categories, and how to call these resources on the front end, I can clearly tell you that Anqi CMS provides comprehensive support for this and has flexible front-end calling methods.### Picture Support Function of AnQi CMS Document Classification AnQi CMS has fully considered the diversity of website content display needs since its design

2025-11-06

How to specify a detailed template for all documents under a category?

As an experienced website operator familiar with Anqin CMS, I fully understand your pursuit of efficiency and consistency in content management.Uniformly specify the detail template for all documents under the category, which not only ensures the unified style of website content display, but also greatly simplifies the follow-up operation and maintenance work.The AnQi CMS provides intuitive and powerful functions, allowing you to easily achieve this goal.The significance of a unified document template in website operation is the key to improving user experience and brand image.

2025-11-06

How to use document recommendation properties to implement content display classification on the front end when adding a new document (such as headlines, recommendations)?

AnQiCMS (AnQiCMS) is an efficient and customizable content management system that provides website operators with a wealth of content management tools.The "Document recommendation attribute" feature is the key to refined content display.It allows operators to tag documents with specific markers in the background, thereby flexibly categorizing and presenting content through the frontend template, such as setting important news as 'headlines' or listing selected articles as 'recommended'.

2025-11-06

How can the keywords of the document be managed and selected efficiently, and does it support a keyword library?

As an experienced CMS website operation person in the security industry, I know the core status of keywords for website content marketing and SEO optimization.Effective keyword management not only enhances content visibility, but is also crucial for attracting target users and improving conversion rates.AnQi CMS provides a powerful and flexible solution in this field, significantly improving my daily operational efficiency.

2025-11-06