How to implement custom display templates for category pages in AnQiCMS?

Calendar 👁️ 75

AnQiCMS provides excellent flexibility in website content management, especially in handling the display of category pages. It is not limited to a fixed layout, but allows users to set personalized display templates for category pages based on different business needs and design concepts.This is an extremely practical feature for operators who hope to enhance user experience, strengthen brand image, or optimize specific SEO strategies through differentiated content display.

How is it implemented to customize the display template of the category page in AnQiCMS?This is mainly due to the flexible template mechanism of the system, which provides two main ways to meet your customization needs.

AnQiCMS template mechanism overview

AnQiCMS's template system is based on a syntax similar to the Django template engine, using.htmlAs a template file suffix, and place all template files in/templateUnder the directory. You can create your own template theme folder here, and organize your template files within it.This design makes template creation very intuitive and easy to manage.

When customizing the category page template, AnQiCMS provides two paths: one is to use the system's predefined naming convention for automatic matching, and the other is to manually specify the template for a specific category through the backend settings.

Method one: using AnQiCMS's convention-based naming for automatic matching

AnQiCMS provides an intelligent template matching mechanism.When you do not explicitly specify a template for a category, the system will automatically search for and load the corresponding template file according to a set of preset rules.This is particularly suitable for scenarios with a large number of categories, and the display structure of these categories is mostly similar.

The most common category list page template, AnQiCMS will try to find the following two files in your template theme folder:

  • General model list templateFor example, if you have an 'article' content model, the system will look for a file named{模型table}/list.htmlsuch asarticle/list.htmlorproduct/list.html)。If this file exists and no more specific template is specified, all list pages of categories belonging to the model will use it.
  • Specific category ID template: If you want to design a unique layout for a specific category (such as a category with ID 12) without manually setting it in the background, you can create a named{模型table}/list-{分类id}.htmlsuch asarticle/list-12.htmlWhen the user visits the article category list page with ID 12, the system will load this more specific template first.

This naming convention allows you to achieve unified or localized design adjustments at a lower maintenance cost when managing a large number of categories.

Method two: flexibly specify the template through the background settings.

If some of your categories require a completely unique display style, even if the default conventions cannot meet the needs, AnQiCMS also provides the powerful function of directly specifying templates in the background.This provides great convenience for operators who need highly customized pages (such as specific product display pages, special topic activity pages, or corporate solution pages).

To specify a category template from the backend, you can follow these steps:

  1. Create a custom template fileFirstly, in your AnQiCMS theme folder (for example,/template/您的主题名/Create a new HTML template file inside, you can place it in any subdirectory, such ascustom/special_category.htmlMake sure the content of the template file meets your design requirements.

  2. Log in to the backend and edit categories: Next, log in to the AnQiCMS backend management interface, navigate to the 'Content Management' menu on the left, and click the 'Document Categories' option.

  3. Specify category templateIn the document category list, find the category you want to customize the template for, and click the "Edit" button on the right.After entering the category editing page, scroll down to find the "Other parameters" section.Here, you will see a text box named "Category Template".

  4. Enter template pathEnter the path and filename of the custom template file you just created relative to the root directory of your theme. For example, if you create a file iscustom/special_category.htmlThen fill incustom/special_category.html.

  5. Apply to subcategory (optional)In the input box below the "Category Template", you will also see an option for "Apply to Subcategories".By default, the category template does not automatically inherit to the subcategories.If you want all subcategories under the current category to use this custom template you have set, you can check this option.

After completing and saving the above settings, when the user visits this specific category page, AnQiCMS will load the custom template specified in the backend to display the content.

Please ensure that the template file path you have entered is accurate, as if the system cannot find the corresponding template file, it may cause the category page to fail to open normally.

Useful hints for custom category template customization

In your custom category template, you can fully utilize various template tags provided by AnQiCMS to obtain and display data. For example:

  • Use{% categoryDetail ... %}Tag to get detailed information about the current category, such as category name, description, Banner image, etc.
  • Use{% archiveList ... %}Tag to get the document list under the category, and it can be sorted, filtered, and paginated according to requirements.
  • Don't forget to optimize the page SEO, through.{% tdk ... %}Tag to ensure the correct setting of page title, keywords, and description.
  • If your website supports mobile, don't forget tomobile/Create the corresponding mobile template under the directory to provide a cross-device browsing experience.
  • During template development, it is a good habit to preview frequently, which can help you discover and correct problems in time, ensuring that the final effect meets expectations.

By combining conventional naming and flexible back-end specifications, AnQiCMS makes template customization for category pages both efficient and powerful.You can choose the most suitable strategy according to your specific needs to create a website page that is both beautiful and practical.


Frequently Asked Questions (FAQ)

1. If the custom category template file I specify does not exist, how will the category page display?

If AnQiCMS cannot find the custom category template file you set at the specified path, the category page will not load normally and display an error message.To avoid this situation, please confirm that the corresponding template file has been uploaded to the correct path after specifying the template name in the background.

2. How to obtain the name and description information of the current category in a custom category template?

In a custom category template, you can use{% categoryDetail with name="Title" %}to obtain the category name,{% categoryDetail with name="Description" %}Get the category description and othercategoryDetailSupported fields to get detailed information about the current category. These tags will automatically identify the category of the current page, no need to specify an ID manually.

3. Can I set different display templates for the PC and mobile end of the same category?

Of course you can. AnQiCMS supports multi-terminal templates. You just need to create a folder namedmobile/in your template theme folder. Then, in `mobile/

Related articles

How to call and display the title, content, and related fields of a document on the AnQiCMS article detail page?

In AnQiCMS, the content detail page is the key area where you display core information and attract readers.Effectively call and display the title, content, and various related fields of the document, which can greatly enhance user experience and the richness of page information.The powerful template engine of AnQiCMS provides an intuitive and flexible way to achieve these goals.## Understanding AnQiCMS Template Syntax AnQiCMS's template system uses syntax similar to Django template engine, it mainly operates data and logic through two forms: * **Double Curly Braces

2025-11-07

How to use AnQiCMS template tags to retrieve and display the system configuration information of the website?

In Anqi CMS, the system configuration information of the website is the foundation for its operation, including the website name, Logo, filing number, address, and other core data.This information is usually needed to be dynamically displayed on various pages of the website (such as the header, footer, contact us page, etc.) to maintain consistency.To facilitate template developers and content operators to efficiently manage and display this information, AnQiCMS provides a simple and powerful template tag that allows you to flexibly obtain and display the system configuration of the website.Where is the system setting of AnQi CMS? First

2025-11-07

How does AnQiCMS's scheduled publishing function ensure that content is displayed accurately on the website as planned?

In today's fast-paced digital world, the timing of publishing website content is often as important as the content itself.In order to coordinate with market activities, seize hot news, or simply to maintain the regularity of content publication, the ability to accurately control the timing of content going live is crucial.AnQiCMS (AnQiCMS) deeply understands this, and its built-in scheduled publishing function is designed to meet this core requirement, ensuring that your website content is displayed accurately and as planned to visitors.### Say goodbye to manual operation

2025-11-07

How to use AnQiCMS pseudo static and 301 redirect function to optimize URL structure to improve SEO display effect?

In website operation, the structure of URL has a significant impact on search engine optimization (SEO) effectiveness.A clear, concise, and descriptive URL that can improve user experience and help search engines better understand page content, thereby improving crawling efficiency and ranking.AnQiCMS is a powerful content management system that provides comprehensive pseudo-static and 301 redirect functions, helping us create an ideal URL structure.### Understanding SEO-friendly URLs and their importance Imagine that

2025-11-07

How to correctly display Markdown formatted mathematical formulas and flowcharts in AnQiCMS?

For users who often need to publish technical articles, tutorials, or academic content, the Markdown editor is undoubtedly a tool that improves efficiency.Its concise syntax makes content creation intuitive and quick. AnQiCMS, as a modern content management system, naturally takes full consideration of the use scenarios of Markdown and provides strong support.However, when we need to insert complex mathematical formulas or draw intuitive flowcharts in Markdown-formatted articles, relying solely on the features of Markdown itself is not enough. At this point

2025-11-07

How does AnQiCMS manage and display single-page content, such as 'About Us' or 'Contact Us'?

In website operation, we often need to create some fixed content, large information independent pages, such as "About Us", "Contact Us", "Terms of Service" or "Privacy Policy" and so on.These pages are usually called single-page content, they are an indispensable part of the website, used to provide visitors with core information, build trust, or guide operations.AnQiCMS provides an intuitive and flexible solution for managing and displaying this type of single-page content.

2025-11-07

How to filter and sort articles by category ID and recommendation attributes when displaying the article list in AnQiCMS?

How to effectively organize and present article lists in a content management system is a key factor that directly affects user experience and website information architecture.AnQiCMS provides a flexible and powerful template tag that allows us to refine and sort articles based on category ID and recommended attributes, thereby achieving accurate content placement and optimized display. ### Understanding the `archiveList` article list tag The display of AnQiCMS article lists depends on the `archiveList` template tag.It is like a universal content query tool

2025-11-07

How to implement nested list display of multi-level categories in AnQiCMS templates?

The navigation structure of the website is the core of user experience, a clear and organized multi-level classification list can not only help users quickly find the content they need, but also effectively improve the website's SEO performance.In AnQiCMS, with its flexible template tag system, achieving the intuitive and efficient display of nested list categories becomes straightforward. ### Understanding AnQiCMS's Classification Structure In the AnQiCMS admin interface, you will find that the classification function allows you to create classifications with hierarchical relationships.This means you can write an article for

2025-11-07