How can you customize templates for specific documents or categories to achieve personalized display?

Calendar 👁️ 70

In AnQi CMS, when you want a specific article, product, category, or independent page to have a unique display effect, the system provides flexible template customization functions to easily achieve personalized content display.This is greatly beneficial for creating brand characteristics, launching special event pages, optimizing the user experience of specific content, and even improving SEO performance.

Why do you need to customize a template for specific content?

Imagine that your website has a \Traditional websites may require developers to modify the core code, but in AnQiCMS, you can easily meet these needs through custom templates.

Custom templates can help you:

  • Highlight the key points of the content:Provide a dedicated layout for important articles or product designs to attract user attention.
  • Optimizing user experience: Offer the most suitable reading or browsing experience based on the type of content.
  • Strengthen brand image:Use unique visual elements and interactive methods for a specific theme.
  • Improve SEO effectiveness:Flexibly adjust the page structure to better meet the crawling and ranking needs of search engines.
  • Bear special functions: For example, provide a dedicated download link area for a download page, or provide a registration form for an event page, etc.

AnQi CMS template system overview

The template files of AnQi CMS are stored in/templatethe directory, each template package has its own independent directory, for example/template/default/. Template files are usually named.htmlSuffix, and written in a syntax similar to the Django template engine, which allows those familiar with front-end development to quickly get started. You will use double curly braces{{变量}}Output data, as well as single curly braces with a percentage sign{% 标签 %}To implement logical judgment, loop traversal, and other functions.

The system itself has provided a set of default template file naming rules, for example, the article detail page may bearticle/detail.html, the category list page might bearticle/list.htmlWhen you want to break these default rules and give special display to specific content, custom templates come into play.

How can you customize templates for specific documents or categories to achieve personalized display?

In Anqi CMS, specifying a custom template for specific content is a very intuitive process, mainly consisting of two core steps: first, prepare your template file, and then configure it simply in the background management interface.

First step: Prepare your custom template file

You need to create or modify a custom template based on the content type you want to customize (article, product, category, or single page) and your design requirements.htmlTemplate file.

  1. Please specify the file location:Place your custom template file in the directory of the currently enabled template package. For example, if your template package is nameddefault, the path is usually/template/default/. To maintain the clarity of file management, it is recommended to create subdirectories based on content type, such as:

    • If it is a special article detail template, it can be placed intemplate/default/article/special-doc.html.
    • If it is a list template of a specific category, it can be placed intemplate/default/category/promo-list.html.
    • If it is a special single-page template, it can be placed intemplate/default/page/about-us.html.
  2. Write the template content:

    • In the template file, you can write standard HTML, CSS, and JavaScript code.
    • It is most important that you need to make use of the rich tags provided by Anqi CMS (such as{% archiveDetail %}/{% categoryDetail %}/{% pageDetail %}etc.) to dynamically retrieve and display content data. For example, to display the article title, you can use<h1>{% archiveDetail with name="Title" %}</h1>.
    • can inheritbase.htmlThis skeleton template is used to maintain the unity of the website's overall style, only modifying the parts that need to be personalized.

Step two: specify the use of a custom template in the background.

After the template file is ready, the next step is to inform Anqi CMS which template to use when rendering specific content. This process varies slightly in the different content types in the backend management interface:

  1. For a single document or product:

    • Enter the backend“Content Management”-u003e“Publish document”or"Edit document".
    • Find below the editing interface,“Other Parameters”Fold the area and expand.
    • You will see a field named“Document Template”. Here, you need to enter the relative path and filename of your custom template file in the currently enabled template directory.
      • For example, if your template file istemplate/default/article/download.htmlthen you should fill inarticle/download.html.
      • The system will use the specified template here to render this specific document first.
  2. For content categories:

    • Enter the backend“Content Management”-u003e“Document Category”.
    • Click the category next to the template you want to customizeEditbutton.
    • Find below the editing interface,“Other Parameters”Fold the area and expand.
    • FindCategory TemplateField. Similar to the document template, fill in the relative path and file name of the template file in the currently enabled template directory.
      • For example, if your template file istemplate/default/category/special-event.htmlthen you should fill incategory/special-event.html.
    • Here is another.Whether to apply to subcategoriesThe option. If you check this option, all subcategories under this category (including their document lists) will inherit and use this custom template, greatly reducing repeated configuration.
  3. For the independent single page:

    • Enter the backend"Page Resources"-u003e“Page Management”.
    • Click on the side of the single page you want to customizeEditbutton.
    • Find below the editing interface,Single page templatefield. Enter the relative path and filename of the template file in the currently enabled template directory.
      • For example, if your template file istemplate/default/page/contact-us-v2.htmlthen you should fill inpage/contact-us-v2.html.

After configuration is complete, save your changes.When the user accesses the document, category, or single page you specify, Anqi CMS will automatically call the personalized template you carefully design, presenting a unique display effect.

Practical tips

  • Clear template naming:Choose meaningful names for custom template files, such asproduct/limited-edition.html, which will make it easier for you to find and manage in the future.
  • Make good use of built-in tags:The Anqi CMS provides a rich set of template tags for retrieving website settings, navigation, documents, categories, users, and other data.Make full use of these tags in your custom template, which can greatly reduce the need for manual content writing.
  • Maintain consistency:Even though it is a custom template, try to maintain consistency with the overall brand style of the website, avoid too much difference in style between pages, which may affect user experience.
  • Testing is crucial:Before the template is put into use, be sure to thoroughly test it on different devices and browsers to ensure that it displays normally and functions perfectly.
  • Backup the template file: Before modifying the template, develop the habit of making backups to prevent unexpected situations.

By using the above method, you can fully utilize the flexible customization capabilities of Anqi CMS, allowing your website content to be presented in the most eye-catching way, truly realizing personalized content management and display.


Frequently Asked Questions (FAQ)

1. Where should I place the custom template file?You need to place the custom template file in the subdirectory of the currently enabled template directory. For example, if your template directory istemplate/defaultThen a custom article template can be placed intemplate/default/article/my-custom-template.htmlWhen specified in the background, you just need to fill inarticle/my-custom-template.html.

2. What will happen if the specified custom template file does not exist?If the background specified custom template file path is incorrect or the file does not exist, AnQi CMS will usually fall back to using its default universal template (for example, article details will usearticle/detail.htmlCategory list will be usedarticle/list.html), or in some cases, the page may fail to load correctly. Therefore, you must ensure that the specified template file is real and the path is correct.

**3. If a document specifies a custom template, and the category it belongs to also specifies a custom template,

Related articles

How to flexibly control the display logic of conditional judgment and loop control tags?

Build dynamic and interactive websites in AnQi CMS, it is inseparable from precise control of the content display logic.This involves conditional judgment (`if`) and loop control (`for`) tags playing a core role.They are like a powerful 'combination punch', making the template no longer a static layout, but one that can intelligently respond and flexibly present content based on data changes.The template syntax of AnQi CMS borrows from the Django template engine, its concise and efficient marking method allows even beginners in template development to quickly get started.

2025-11-07

How to define and use variables in AnQiCMS templates to display dynamic content?

When building a website, we all hope that the content can change flexibly according to different pages and different data, rather than unchanging static text.AnQiCMS leverages its high-performance architecture based on the Go language and a flexible Django-like template engine, providing us with powerful dynamic content display capabilities.And at the core of all this, it cannot be separated from the definition and use of 'variables'. Mastering how to define and use variables in the AnQiCMS template is like mastering the key to activating the dynamic vitality of the website.This is not just a technical operation, but also the realization of content marketing and SEO

2025-11-07

How to organize directory structure of AnQi CMS template files to manage content display?

For users of AnQiCMS, understanding the organization of template files is the key to efficiently managing website content display.A clear and orderly template directory structure, not only allows you to easily customize the appearance of the website, but also greatly improves the flexibility and efficiency of content operation.The template files of Anqi CMS use `.html` as the suffix and are stored in the `/template` folder under the root directory of the website.And all the style sheets, JavaScript scripts, images, and other static resources used in all templates have their own home

2025-11-07

How to configure Anqi CMS to support adaptive, code adaptation, or PC+Mobile independent site display mode?

In the current internet environment, it has become a norm for users to browse websites on various devices. How to ensure that your website presents a**good effect on different devices is one of the keys to the success of website operation.AnQiCMS (AnQiCMS) is well-versed in this, providing flexible and diverse display mode configurations, allowing you to easily switch between adaptive websites, code adaptation, or PC+Mobile independent sites according to your actual needs.This article will detail how to configure these display modes in Anqi CMS, ensuring that your content shines on any screen.###

2025-11-07

How does Anqi CMS automatically extract the first image of the document content as a thumbnail for display?

In website content operation, carefully selecting and setting thumbnails for each article or product page is a time-consuming and important task.A captivating thumbnail can significantly increase click-through rate, optimize user experience, and benefit SEO performance.However, facing an overwhelming amount of content, manually uploading and adjusting thumbnails will undoubtedly become a huge burden.AnQi CMS deeply understands this, and for this reason, it provides a smart and flexible solution that automatically converts the first image of the document content into a thumbnail, greatly simplifying the operation process.## Smart Extraction

2025-11-07

How to add recommended attributes (such as headlines, slides) to control the priority of display on the homepage?

In website operation, how to efficiently display important content, ensure that they can be found first when users visit the homepage, is the key to improving user experience and conversion rate.The Anqi CMS provides a flexible "recommended attribute" feature, allowing us to easily control the display priority of documents, whether as the headline news of the website or prominently displayed in the carousel, it can achieve precise control.

2025-11-07

How does the custom URL feature affect the display links of documents and categories on the front page?

When operating a website, the structure and readability of links play a crucial role.A clear and friendly URL not only improves the user experience but is also an indispensable part of search engine optimization (SEO) strategy.Anqi CMS is well-versed in this, providing powerful custom URL functions that allow you to flexibly shape the display links of documents and categories on the front page. ### The Core Value and Function of Custom URL The custom URL feature allows us to convert traditional dynamic links composed of IDs into more descriptive and meaningful static or pseudo-static links.

2025-11-07

How to set up a timed publishing feature to control the online display time of documents?

In content operation, the timing of content release is often a key factor in determining its communication effect.In order to seize specific marketing opportunities, maintain the rhythm of daily updates, or prepare holiday content in advance, a flexible scheduling publication feature can greatly enhance operational efficiency.AnQiCMS (AnQiCMS) knows this well and has specially provided a powerful scheduled publishing function to allow you to easily plan the content release time and achieve automated operation.This feature is designed to help you reduce cumbersome manual operations, making content operation more strategic and automated.

2025-11-07