How to set up independent custom templates for specific articles, categories, or single pages to achieve personalized content display?

Calendar 👁️ 70

In content operation, creating unique visual and functional experiences for different parts of the website is crucial for enhancing brand image, optimizing user experience, and accurately conveying information.AnQiCMS (AnQiCMS) fully understands this and provides flexible template customization capabilities, allowing us to set personalized display templates for specific articles, categories, and even independent single pages, thus realizing differentiated content presentation.

The core of this feature lies in its ability to allow us to break free from the limitations of the global template of the website, to design and apply specific layouts or styles targetedly, in order to better match the content theme or operational objectives.For example, an important promotional article may need a striking full-screen layout, a product category page may require a specific product display card layout, and a single-page "About Us" page may need a concise and professional introduction template.

Overview of AnQi CMS template mechanism

The AnQi CMS template system is based on a template engine syntax similar to Django, using.htmlfiles as template carriers, and are stored uniformly in the root directory of the website./templateIn the folder. Each website theme has its own template directory, for example/template/default/. This structure is clear and easy to manage, laying a foundation for our subsequent personalized template settings.

To achieve personalized content display, there are mainly two ways: first, by using the template naming rules built into Anqi CMS, allowing the system to automatically identify and apply; second, manually specifying the template file for the content in the background.

The first method: using built-in template naming rules (automatically applied)

AnQi CMS has a smart template search mechanism. If we create template files according to a specific naming convention, the system will automatically apply it to the corresponding content without any additional settings.This provides great convenience for some routine personalized needs.

The following are the default custom template naming formats supported by Anqi CMS:

  • Document (article/product) detail page: {模型table}/{文档id}.htmlFor example, if the article model table name isarticleThere is an article with ID is123, then you can create a namedarticle/123.htmltemplate file. When accessing this article, the system will automatically use this template.
  • Document list page (category page): {模型table}/list-{分类id}.htmlSimilarly, for the article category with ID5you can create aarticle/list-5.htmlThe template, the system will use it to render the article list page of the category.
  • Single page detail page: page/{单页面id}.htmlIf there is a single page ID of10, then createpage/10.htmlto achieve automatic application.

Further, we can also use custom URL aliases to name template files, making the template names more readable. For example, if the custom URL alias for the single-page "About Us" isabout-usSo, you can create onepage/about-us.htmlThe template will be applied automatically by the system.

The second way: specify the template manually through the background (flexible customization)

When our personalized needs cannot be met through naming rules, or when we want to control the application of templates more accurately, Anqi CMS allows us to specify template files directly in the background for articles, categories, or single pages.

Before making any background settings, we need to create our customized.htmltemplate file in the directory of the current template theme. For example, if you are usingdefaultTopic, you can in/template/default/Create one under the directoryspecial-article.htmlorproduct-promo.htmletc. files.

Next, we will introduce how to manually specify according to content types:

  1. For single articles or products:

    • Log in to the AnQi CMS backend, navigate to the 'Content Management' module, and select 'Document Management'.
    • Find the article or product you want to apply a custom template to, and click the "Edit" button on the right.
    • At the bottom of the edit page, there is usually a field called "Document Template".
    • Enter the name of the custom template file you created, for examplespecial-article.htmlPlease note that you only need to fill in the file name, not the path or file extension.
    • After saving the changes, the article or product will use the one you specified when accessed on the front end.special-article.htmlto display the template.
  2. For specific categories and their documents:AnQi CMS provides two-level granularity control in the category template settings:

    • Category list page template:
      • Navigate to the "Content Management" module in the background and select "Document Category."}
      • Find the category you want to apply the custom template to, click the 'Edit' button on the right.
      • In the editing page, there is a field named "Classification Template". This template is usually used to render the list page of the category, for examplelist-with-sidebar.html.
      • You can also check the option 'Apply to subcategories'. If checked, all subcategories under this category will inherit this template setting.
    • Template for articles/products detail page under the category:
      • In the same category editing page, there is also a "Document Template" field.
      • This field allows you to set up for the category underAll articles or product detail pagesStandardize a template. For example, if you want all products in a certain product category to useproduct-detail-v2.htmldisplay, you can fill it in here.
      • This setting is also affected by the 'Apply to child categories' option, if checked, the documents under the child categories will also inherit this template.

    Through these two template settings, we can achieve dual personalized control over the category page and its document detail pages.

  3. For the single page:

    • Log in to the AnQi CMS backend, navigate to the 'Page Resources' module, and select 'Page Management'.
    • Find the single page you want to apply a custom template to, and click the 'Edit' button on the right.
    • At the bottom of the editing page, there will be a field named 'Single Page Template'.
    • Enter the name of the custom template file you created, for exampleabout-us-style.html.
    • After saving the changes, the single page will use the one you specified when accessed on the front endabout-us-style.htmlto display the template.

The template file placement and structure

All custom template files should be placed in the theme directory you are currently using. For example, if your theme folder isdefault, then the path to your template file should be/template/default/. You can place it directly in this directoryspecial-article.html, you can also create subdirectories based on content models or other logic, such as/template/default/article/special-article.html.

AnQi CMS encourages modular design, you can createpartial/Store reusable code snippets (such as sidebars, breadcrumb navigation), or createbash.htmlas a common header and footer, through{% include "partial/header.html" %}or{% extends "base.html" %}tags to reuse code, keeping the template neat and efficient.

注意事项 when designing a custom template

  • Start from an existing template:The simplest way is to copy an existing one (for examplearticle/detail.htmlThe template file, then modify it on this basis. This ensures that you have a complete and correct starting point.
  • Familiarize yourself with the template tags:AnQi CMS provides rich template tags (such asarchiveDetail/categoryDetail/systemetc.), used to obtain various data. In a custom template, you need to flexibly use these tags to display the required content. For example, using{{archive.Title}}to display the article title, or{% archiveList ... %}Call related article list.
  • Ensure the file exists and is named correctly:Whether automatically applied or manually specified, it must be ensured that the template file actually exists in the correct path and that the filename matches the set or naming rules in terms of case sensitivity.
  • Test and debug:After modifying the template, be sure to visit the corresponding page on the front end to test and confirm that the display effect meets expectations.If an error occurs, you can check the background logs or the error information on the front-end page for troubleshooting.

By using the above method, you can fully utilize the template customization capabilities of Anqi CMS, for each content module of the website

Related articles

How to dynamically retrieve and display the title and link of the previous and next articles on the article detail page?

When browsing articles on a website, navigation links such as 'Previous' and 'Next' often appear at the bottom.This seemingly simple detail actually has a significant impact on user experience and the consistency of website content.It not only guides visitors to continue exploring more content, helps to increase the average page visit duration, but also optimizes the internal link structure of the website.For friends using AnQiCMS, implementing this feature is much simpler than imagined, as it comes with powerful template tags that make it easy to dynamically retrieve and display this navigation information.###

2025-11-08

How to use the `categoryList` tag to build and display a multi-level, nested category navigation menu?

In website operation, a clear and easy-to-navigate menu structure is a core factor in improving user experience and search engine friendliness.For websites with a large amount of content or a variety of product lines, it is particularly important to build a multi-level, nested category navigation menu.AnQiCMS provides powerful template tag functions, where the `categoryList` tag is the key to achieving this goal.This article will delve into how to use the `categoryList` tag to flexibly build and display your multi-level category navigation menu

2025-11-08

How to configure and display multilingual content in AnQi CMS to serve users in different regions?

In today's global internet environment, enterprises and content operators often need to provide content to users from different countries and regions.AnQiCMS (AnQiCMS) understands this need and therefore provides flexible and powerful multilingual content configuration and display capabilities, helping users easily expand into international markets and directly reach audiences with different language preferences.### Overview of AnQi CMS Multilingual Capabilities AnQi CMS considers multilingual support as one of its core strengths, aiming to provide users with a complete global content publishing solution

2025-11-08

How to implement lazy loading of images in article content to improve page loading speed and user experience?

In today's fast-paced online world, website loading speed is crucial for user experience and search engine rankings.If your website content contains a large number of images, optimizing their loading method will be a key step in improving website performance.Image lazy loading (Lazy Load) is a highly efficient solution. Why Image Lazy Loading is So Important? While website images can enrich content and enhance visual appeal, they are also often the main reasons for slow page loading.When a page carries many high-resolution images

2025-11-08

Does AnQi CMS support the rendering of content in Markdown format and can it correctly display mathematical formulas and flowcharts?

For Anqi CMS users, whether they can use Markdown format for content creation and smoothly display complex mathematical formulas and visualized flowcharts is a key consideration for enhancing content expression.It is pleasing to see that Anqi CMS indeed provides good support for these advanced content formats, and through a set of flexible configuration mechanisms, allows content creators to easily achieve this goal. ### Enable Markdown Editor First, content creators need to make simple settings in the Anqi CMS backend.Enter the "Global Settings" menu

2025-11-08

How to dynamically display a list of friend links in the footer or sidebar of a website?

In website operation, friendship links are one of the important ways to enhance website authority, obtain external traffic, and improve user experience.A system that is easy to manage and can dynamically display friend links will undoubtedly greatly improve operational efficiency.AnQi CMS is an efficient content management system that provides flexible friend link management features, allowing you to easily display these valuable external resources in the footer or sidebar of your website.Friend link management in AnQi CMS is very intuitive.You only need to log in to the backend management interface of AnQi CMS

2025-11-08

How to automatically generate and display breadcrumb navigation that conforms to SEO standards on a webpage?

In website operation, providing clear navigation paths for visitors while optimizing the crawling efficiency of search engines is a key link to improve user experience and website SEO performance.A breadcrumb navigation is a feature that can intuitively display the hierarchical position of the user on the current page and provide a convenient return path.For websites built using AnQiCMS, we can conveniently utilize its built-in features to automatically generate and display breadcrumb navigation that complies with SEO standards.###

2025-11-08

How to configure the pagination display of the article list and allow custom pagination links and styles?

In website operation, as the content volume grows, how to effectively organize and present these contents so that users can easily browse them is the key to improving user experience and website performance.The pagination display of the article list is an important means to achieve this goal.AnQiCMS provides a powerful and flexible template tag feature, allowing us to easily configure the pagination display of article lists and customize the link structure and visual style of pagination according to actual needs.### Configure the article list to enable pagination Enable pagination for the article list

2025-11-08