How to set up independent display template files for specific articles or categories?

Calendar 👁️ 70

In daily website operation, we often encounter such situations: some articles are in-depth reports, some are event promotional pages, and some are corporate profiles or product details.Each has unique display requirements, and if they all follow the website's common template, it may seem monotonous and fail to fully exert the attractiveness of the content.AnQi CMS is an efficient and flexible content management system that fully considers this personalized demand, allowing us to set independent display template files for specific articles, categories, even single pages, making the content display more tailored and impactful.

Imagine you are in the middle of an important product launch and need a unique landing page to attract users;Or a deep industry analysis report, hoping to present it to the reader in a more professional format to enhance the authority of the content.At this time, it is particularly important to set up a dedicated template for this specific content.This can not only make your website content more differentiated and recognizable, but also bring significant improvement in user experience, brand image, and even search engine optimization (SEO).By customizing templates, we can better control the visual presentation of content, guide users to focus on key information, thereby improving conversion rates and user stickiness.

Anqi CMS template mechanism overview

The template system of Anqi CMS is designed to be very flexible. It uses.htmlas the template file suffix, and stored in/templateIn the different theme folders under the directory. The system uses a syntax similar to the Django template engine, allowing you to easily get started with template development and modification.Whether it is adaptive, code adaptation, or PC + mobile independent site mode, AnQiCMS can provide perfect support.

In the template loading order, AnQi CMS has a clear priority: it will first check if the specific content has specified a custom template file. If specified, it will use this custom template; if not, it will follow the predefined rules (for example, try to match first){模型table}/{文档id}.htmlSuch automatic template naming, then fallback to the general template) for loading. This mechanism provides us with great convenience for fine-grained control of content display.

Core operation: specify an independent template for specific content

Set independent templates for articles, categories, or single pages, which mainly consists of two steps: first, prepare your custom template file, and then specify the file in the background for the corresponding content.

1. Prepare your custom template file.

First, you need to be in the current website template directory (for example, if you are using the default template, it is usually/template/default/Create or upload your custom template file. Give the template file a clear, easy-to-identify name, such asspecial-promotion.htmlUsed for special promotion pages, orindustry-report.htmlUsed for industry reports.

When writing these custom templates, you can take advantage of the powerful template tag features of Anqicms to retrieve and display dynamic content. For example,{% archiveDetail %}Tags can help you get detailed information about the article,{% categoryDetail %}used to get category details,{% pageDetail %}it is used to get the content of a single page. At the same time, you can also use{% extends %}tags to inherit the common skeleton template of your website (such asbash.htmlThis way, you do not have to rewrite the header, footer, and other common parts from scratch, just focus on the unique design of the content area, which greatly improves development efficiency.

For example, if you want the article detail page to have a unique layout, you can/template/default/article/Create a file namedmy_custom_detail.htmlfile and use{% extends 'bash.html' %}to inherit the basic layout, then use{% block content %}to rewrite the display of the content area.

2. Specify the template in the background

When your custom template file is ready, the next step is to tell AnQi CMS which content should use this new template.This process is very intuitive, usually it can be completed on the content editing page.

  • Set an independent template for a specific article:

    • Enter the Anqi CMS background, navigate to "Content Management" -> "Document Management".}
    • Select the article you need to customize, click the 'Edit' button.
    • Find the collapsible area named 'Other Parameters' at the bottom of the document editing interface and expand it.
    • You will see a text box named "Document Template". Here, enter the path and name of the custom template file you just created, for examplearticle/my_custom_detail.htmlOr if your template file is directly placed in the theme root directory, you can fill it directlyspecial-promotion.html.
    • After saving the article, visit the front page of the article, and you will see that it has applied the custom template you specified.
  • Set an independent template for a specific category:

    • Enter the Anqi CMS backend, navigate to 'Content Management' -> 'Document Category'.
    • Select the category you need to customize the template, click the 'Edit' button.
    • Below the category editing page, you can also find the 'Other Parameters' area and expand it.
    • Find the input box for 'Category Template' and enter the path and name of your custom template file, for examplecategory/product_list.html.
    • Here is another very useful option is whether to apply to subcategories.If you want all subcategories under this category to use this custom template, just check this option.Otherwise, only the current category will be applied, and child categories will continue to use their own or parent templates.
    • After saving the category, visit the front page list of the category to see the changes in the template.
  • Set an independent template for a specific page:

    • Enter the Anqi CMS backend and navigate to 'Page Resources' -> 'Page Management'.
    • Select the single page template you need to customize (such as "About Us"), click the "Edit" button.
    • Find the "Single Page Template" input box at the bottom of the single page editing interface.
    • Enter the path and name of your custom template file, for examplepage/about_us_unique.html.
    • After saving a single page, visit the page, and it will be displayed with a brand new template style.

Tips and注意事项

  • Accuracy of the pathEnsure that the path entered for the template file in the background is accurate. This path is relative to the root directory of the currently active theme template (i.e./template/您的主题文件夹/In this context.
  • Test in time.: After you set or modify a custom template, you should immediately visit the front page for testing to ensure that everything displays normally and that all dynamic content can be loaded correctly.
  • Unified EncodingPlease ensure that all template files use UTF-8 encoding to avoid garbled characters.
  • Make full use of tags: AnQi CMS provides a rich set of template tags and filters, which are powerful tools for you to retrieve and process data in custom templates.Familiarize and make good use of these tags, which can make your template more powerful and dynamic.
  • Mobile AdaptationIf your website uses a PC + mobile independent site mode, don't forget tomobile/create a corresponding mobile version of your custom template in the directory to ensure that there is also a good one on the mobile end

Related articles

On the document detail page, how to call and display the custom model field content of the article?

The flexible content model of AnQiCMS (AnQiCMS) is a very powerful tool that allows us to add dedicated fields for different types of content (such as articles, products, events, etc.) based on the actual needs of the website.This means that our content is no longer limited to fixed titles, summaries, and content, but can carry more diverse and structured information.How do we call and display the content of these custom model fields on the document detail page? Next, let's explore the various flexible ways provided by Anqi CMS.###

2025-11-08

How to implement personalized front-end display for different types of content (articles, products, single pages) in AnQi CMS?

In AnQi CMS, achieving personalized front-end display of different types of content (such as articles, products, and single pages) is one of its core advantages, and it is also a key factor for content operators to achieve brand differentiation and improve user experience.This is mainly due to the flexible content model design and powerful template customization capabilities of Anqi CMS. ### Flexible Content Model: The Foundation of Personalized Display The core of Anqi CMS lies in its "flexible content model".This means you are not limited to fixed "article" or "product" types, but can customize various content models according to your actual business needs. For example

2025-11-08

How to customize the display fields of an Anqi CMS content model to meet specific business requirements?

In website operation, the diversity and personalization of content are the key to attracting users and improving efficiency.AnQiCMS (AnQiCMS) understands this and therefore provides powerful content model customization features, allowing us to flexibly adjust the display fields of content according to specific business needs.This article will take you in-depth to understand how to use this powerful feature to create a content management experience that is more tailored to your business scenario.Why do we need to customize content model fields?You may encounter such a situation: The default "article" or "product" model is general, but in actual operation

2025-11-08

How to configure custom parameters in the background of AnQiCMS and flexibly call and display them in the front-end template?

In website operation, we often encounter the need to add personalized information outside of standard fields for content or the global website.This information may be a description of the unique features of a website, product parameters, specific attributes of an article, or even multi-channel contact information.AnQiCMS (AnQiCMS) fully understands the importance of this flexibility, and therefore provides powerful custom parameter configuration features, allowing you to easily define the required data in the background and flexibly call and display it in the front-end template.

2025-11-08

How does Anqi CMS template support adaptive, code adaptation, and independent display mode on PC and mobile?

How to ensure that the website can provide a high-quality user experience on different devices is a challenge that cannot be ignored in today's content marketing and website operations.AnQiCMS (AnQiCMS) knows this, therefore it provides flexible and diverse adaptation modes in template design and content display, allowing users to easily deal with various terminal access scenarios according to their own needs.

2025-11-08

What are the common variable naming and tag syntax rules (such as `{{variable}}` and `{% tag %}`) when making AnQiCMS templates?

To create templates in AnQiCMS and master its variable naming and tag syntax rules is the core.The system is developed based on the Go language, the template engine borrows the syntax style of Django and Blade, making content output and logical control very intuitive.When you are doing template development, you will mainly encounter two basic syntax structures, each of which has different responsibilities.### Core grammar structure: variable output and logical control First are double curly braces `{{ variable }}`, which have a very direct function

2025-11-08

How to efficiently organize and reference common page header, footer, and other code snippets in the front-end page template?

Manage front-end page code in AnQi CMS, especially the header, footer, and other code snippets that need to be repeated on multiple pages, which is a key to improving development efficiency and website maintainability.AnQi CMS provides a powerful and flexible template engine, allowing us to organize and reference these common codes in an elegant way. ### The Importance of Template Reusability Imagine if your website has dozens, even hundreds of pages, each of which independently contains the complete header, navigation, and footer code. When the website's logo needs to be replaced, or the footer copyright information needs to be updated

2025-11-08

How to customize the display layout of content on the frontend page in Anqi CMS?

AnQiCMS (AnQiCMS) is an efficient and flexible content management system that provides us with great freedom with its powerful template functions and content model, allowing us to finely control the layout of content on the front-end page according to the actual needs of the website.To achieve this goal, we need to deeply understand the template engine, content model, and built-in tags of Anqicms.

2025-11-08