The Anqi CMS provides great flexibility for website content management, and customizing the display style of category pages is a very practical feature.By setting custom templates for different categories, you can easily allow news, products, case studies, and other types of category pages to present unique designs and content layouts, thus better meeting user browsing needs and brand display strategies.

Why do you need a custom category template?

By default, Anqicms will use a set of generic list templates for all categories (usually{模型table}/list.htmlThis may lead to a uniform visual effect on all category pages.However, different categories often carry different content attributes and marketing objectives.For example, a "Company News" category may require a concise list of titles and publication dates, while a "Product Showcase" category may need large images, prices, and more detailed product parameter filtering features.By customizing the template, you can break this uniformity, tailor a unique display interface for each category, thereby:

  • Improve user experience:Provide the most suitable layout and information display method based on content type, allowing users to find the information they need faster.
  • Strengthen brand image:Design a unique style for a specific category to better convey brand characteristics and professionalism.
  • Optimize content marketing:Highlight key information, guide user behavior, and improve conversion rates.
  • Achieve personalized display:Even different categories under the same content model can have completely different visual presentations.

The AnQi CMS is exactly based on its flexible content model and easily expandable template mechanism, making such customization possible.

The core mechanism of the AnQi CMS custom category template

Safe CMS provides two main ways to implement custom templates for category pages:

  1. Follow the default naming conventions:The Anqi CMS supports some default template file naming rules.If the template file you create meets these rules, the system will automatically recognize and apply it, without any additional settings in the background.

    • For a specific category, you can create a template named{模型table}/list-{分类ID}.htmlA template file. For example, if you have a category ID of 10 for an article model, you can createarticle/list-10.html.
    • For all categories under a specific content model (unless overridden by a more specific category template), you can create a template file named{模型table}/list.htmlas the default template for the model category page.
  2. Specify the template through the back-end interface:This is the most commonly used and flexible way. You can specify which custom template file to use for this category in the category editing page on the backend.This method has a higher priority than the default naming convention, that is, if you specify a custom template for a category, the system will prioritize the template you manually specify even if there is a template file that conforms to the naming convention.

Next, we will focus on explaining the specific steps for specifying a custom template in the back-end.

Specific operation steps

To set a custom template for the categories in AnQi CMS, to change the page display style, it is mainly divided into the following steps:

Step 1: Prepare the custom template file

First, you need to create or modify a template file in the current template theme folder.

  1. Find the template directory:Log in to your server file system, locate to the installation directory of AnQi CMS under/template/Folder. In this folder, you will see the name of the template theme you are currently using (for exampledefault) Go to the template theme folder.
  2. Create a template file:Within your template theme folder, you can create a new one under the corresponding subfolder (such asarticle/productetc).htmlFile, or create directly in the root directory. For example, if you want to customize a template for article categorization, you can createarticle/custom-article-list.html. Give the template file a meaningful name for easy identification in the future
  3. Write the template content:
    • Start with an existing template:The simplest way is to copy the existing category list template from the current template theme (for examplearticle/list.htmlorproduct/list.html), and then paste its content into the one you just createdcustom-article-list.htmlthe file.
    • Apply AnQi CMS tags:In the template file, you can use various tags provided by AnQi CMS as needed, for example:
      • {% archiveList %}Used to get the document list under the category. You can set different parameters to control the display quantity, sorting method, etc.
      • {% categoryDetail %}Used to get detailed information about the current category, such as the category title, description, Logo image, etc.
      • {% system %}Used to get global website settings information.
      • {% pagination %}Used to generate pagination links.
      • And various conditional judgments ({% if %})、looping over({% for %}) etc. Django template engine syntax.
    • Design layout and style:In this file, you can freely adjust the HTML structure, introduce CSS styles (usually stored in/public/static/the directory), to achieve the page layout and visual effects you want.

Step 2: Enter the category management interface

Log in to the AnQi CMS backend management system, find and click in the left navigation bar“Content Management”and then select“Document Category”.

Step 3: Select and edit the target category

In the document category list, find the category you want to apply a custom template to, click the one on the right ofEditthe button to enter the category editing page.

Step four: specify the category template

In the category editing page form, scroll down and find“Other Parameters”the section and expand it. You will see a field namedCategory Templatefield.

  1. Enter the template file name:Enter the relative path and file name of the custom template file you created in the "Classification Template" field. Please make sure to fill it in correctly, for exampleStep 1中创建的自定义模板文件的相对路径和文件名。请务必填写正确,例如article/custom-article-list.html.Note:Do not include the name of the template theme folder when filling in, just need the relative path starting from the content model folder (if your template file is placed directly inarticleIn the folder) or directly write the filename (if the template file is placed in the root directory of the theme template).
  2. Consider inheritance of subcategories:Under the "Category Template" field, you will also see a field namedWhether to apply to subcategories.
    • If you want all subcategories (including multi-level subcategories) under this category to follow your current custom template, please check this option.
    • If you want the subcategory to keep its default template or have an independent custom template, do not check this option.

Step five: Save and verify

  1. Save category information:Click the bottom of the page.“OK”Button, save your changes to the category settings.
  2. Clear the cache:Return to the backend main page, click the left navigation bar.“Update Cache”Button, clear the system cache to ensure that template changes take effect immediately.
  3. Check front desk verification:Open the browser, visit the category page you just modified (by clicking the "View" link in the category list or entering the category URL directly), check if the new custom template has been successfully applied, and whether the page style and content layout meet your expectations.

By following these steps, you can set up exclusive custom templates for categories in AnQi CMS, achieving highly personalized website page display.


Frequently Asked Questions (FAQ)

1. Where should my custom template file be placed?Your custom template file should be placed in the directory where AnQi CMS is installed./template/您的模板主题名称/In the folder. For example, if you are using a template theme isdefault, and the template is used for the classification list of article models, you can place it in/template/default/article/the directory, the filename ismy-custom-category.html.

2. Why did I set up the category template but the front page still shows no changes?This usually has several reasons:

  • Cache not cleared:After modifying the template or background settings, please make sure to go to the background and click “Update Cache”.
  • Template file name or path error:Please check carefully.