How to configure specific template files for the homepage, detail page, list page, etc. of AnQiCMS to control the display?

Calendar 👁️ 62

AnQiCMS, with its high-performance and flexible customization features developed in Go language, provides strong control over the display of website content.No matter whether you are running a small and medium-sized enterprise website, a personal blog, or need to manage multiple sites, understanding how to configure exclusive templates for different pages is the key to enhancing the personalization and user experience of the website.

In AnQiCMS, the core of content display lies in the template files.These files determine the visual layout, content formatting, and interactive elements of the website.AnQiCMS uses a syntax similar to the Django template engine, which allows users familiar with common template languages to quickly get started, even for those new to it, the natural and intuitive tag and variable usage is easy to understand.

The basic structure of the template file and its location

All related to the template.htmlThe files are stored centrally in/templateIn the root directory. Typically, each independent template theme will have a dedicated subdirectory, such as one nameddefaultThe template, all its files will be located in/template/default. In this template theme directory, you will find aconfig.jsonfile that records the name, version, author, and other basic information of the template, and more importantly, it definestemplate_typeThis determines whether your website adopts an adaptive, code adaptation, or PC + mobile independent site mode.

except.htmlTemplate files, CSS styles, JavaScript scripts, and static resources related to the template, will be stored in one place,/public/static/In the catalog, this keeps the project structure clear and tidy. When editing template files, make sure the file encoding is UTF-8 to avoid garbled text on the page.

How AnQiCMS automatically identifies and matches templates

One of the design philosophies of AnQiCMS is 'convention over configuration', which means that in many cases, the system will automatically match template files according to a set of predefined naming rules, saving you the trouble of manually specifying them.

For example, AnQiCMS will try to load the homepage of the websiteindex/index.htmlor directly under the template root directory in folder organization modeindex.htmlor in flattened mode.

For list pages and detail pages, the intelligent matching mechanism of AnQiCMS is more flexible:

  • List page (category page)If you have an "article" model, the system will first look forarticle/list.htmlAs a general article list template. If you want a specific category (such as the "News Information" category with ID 10) to have a unique layout, AnQiCMS will try to findarticle/list-10.htmlsuch a file.
  • Detail page (document page)Similarly, the system will try to load for the article detail page,article/detail.html. If you need to display a specific article (such as the 'Product Release' article with ID 25) in a different style, you can createarticle/detail-25.html.
  • single pageFor pages like "About Us", the default template might bepage/detail.htmlWhile for a specific page with ID 5, the system will look forpage/5.html.

This automatic matching mechanism greatly simplifies template management, you just need to name the files according to specific rules, and AnQiCMS will understand.

Fine-grained control: Manually specify a specific page template

Although the automatic matching function of AnQiCMS is very convenient, we may need to have more fine-grained template control for individual pages in some complex scenarios.AnQiCMS provides the option to manually specify the template path for a specific page in the backend, making customization easy.

  1. Global shared template fragmentIn your template directory, there is usually abash.htmlFiles are used to store the common header, footer, and other public area codes of a website. In addition,partial/Directories are often used to store reusable code snippets such as sidebars and breadcrumb navigation. Through{% include "partial/header.html" %}Such labels, you can easily introduce these shared contents on any page.

  2. Set an independent template for a single category.In the AnQiCMS backend, under "Content Management" -> "Document Category", when editing a category, you will see a "Category Template" field. Here, you can enter a completely custom template file path, such as specifying a named template for your "Industry Information" category.article/industry-news-list.htmlThe template. Furthermore, you can choose to "apply to child categories" so that all child categories under this category can inherit this template and achieve a unified style.Moreover, there is an 'Document Template' option in the category settings, which allows you to specify a detail page template for all documents under this category, for examplearticle/news-detail.html.

  3. Specify a dedicated template for a single documentIn AnQiCMS backend, under "Content Management" -> "Publish Document" or edit a document, there is a field called "Document Template". Suppose you have an article about "Latest Product White Paper Download" and you want it to have a unique layout with a download button and customer case details, you can create aarticle/whitepaper-download.htmlTemplate, and enter the path in this field. This will load the specific article with the specified template instead of the general document detail template.

  4. Set a unique template for a single independent pageIn the AnQiCMS backend under 'Page Resources' -> 'Page Management', when editing a single page, there is also a 'Single Page Template' field. If you want to design a special layout for the 'Contact Us' page that includes a map, form, and contact information for multiple departments, you can create apage/contact-us.htmlThe template, and specify it in the background.

With these flexible configuration methods, AnQiCMS ensures that you have absolute control over the display of every bit of content on your website.Whether it is to follow the system conventions or manually fine-tune, it can make your website stand out in both visual and functional aspects.

The filling and dynamic display of the template content.

Once the template file is configured, the next step is how to display dynamic content in these templates.AnQiCMS template engine supports various tags and filters, allowing you to easily retrieve data from the database and display it on the page.

Related articles

Template creation in progress, how do the public code (bash.html) and snippet directory (partial/) affect the page display?

In Anqi CMS, when we start building or modifying website templates, we come across some core files and directory structures, among which the public code file `bash.html` and the code snippet directory `partial/` play a crucial role in the final page display.They are not just a simple pile of template files, but also the 'skeleton' and 'building blocks' that make up the structure and display logic of the website, allowing our website to maintain consistency while having high flexibility and maintainability.

2025-11-07

How does the AnQiCMS v2.0.1 version's new article content batch replacement and paraphrasing feature change the display of content?

## AnQiCMS v2.0.1: How do the content renewal, batch replacement and pseudo-original function change the website display?Today, in the increasingly fierce digital marketing, website content must not only be of high quality but also maintain freshness and flexibility.For content operators, how to efficiently manage and optimize a large amount of content while ensuring its good performance in search engines and in front of users is always a challenge.AnQiCMS v2.0.1 version brings the batch replacement and paraphrasing function of article content, which is designed to solve these pain points, and they are implemented in an intelligent way

2025-11-07

How do the new model features in AnQiCMS v2.1.1 affect the display logic of articles and products?

Since its launch, AnQiCMS has been favored by users for its concise, efficient, and flexible features.In the latest v2.1.1 version, we welcome a major feature update - a brand new 'Model' feature.This seemingly technical improvement actually has a profound impact on the way we publish and display website content on a daily basis, especially for core content types such as articles and products.Model Function: Blueprint of Content Structure In simple terms, "model" is like a blueprint or skeleton for content. In the past

2025-11-07

How to configure AnQiCMS Apache reverse proxy to correctly display website content?

AnQiCMS is an efficient content management system developed based on the Go language, which usually runs on a specific port of the server, such as the default port 8001.In order for users to access the website through common domain names instead of adding a port number at the end of the address, we need to configure a reverse proxy.

2025-11-07

What is the impact of folder organization mode and flat file organization mode on template production and content display?

When building website templates in AnQi CMS, the organization of template files is one of the core issues you need to pay attention to.AnQi CMS provides two main template organization modes: **Folder Organization Mode** and **Flattened File Organization Mode**.These two modes have their own characteristics, and their choice will directly affect the efficiency of your template creation and the final presentation of the content.Understand their differences and impacts, which can help you make more informed decisions based on project needs.### Folder Organization Mode

2025-11-07

How to get and display the website global information using the AnQiCMS system settings label `system`?

In website construction and daily operation, we often encounter situations where we need to display some global information, such as the name of the website, Logo, filing number, contact information, etc.This information runs through the entire website and needs to be consistent across multiple pages.AnQiCMS provides an extremely convenient way to handle this type of global information, which is through its built-in `system` template tag.

2025-11-07

How to dynamically display the `contact` label of the company contact information?

In website operation, clear, accurate and easy-to-update business contact information is a crucial link.Imagine if you need to update your contact phone number or email, do you need to manually modify every web page that contains this information?This is not only time-consuming and labor-intensive, but may also lead to inconsistent information due to omissions, affecting user experience and brand image. AnQiCMS (AnQiCMS) is well-versed in this, and to address this pain point, it has specially provided the **contact label `contact`**.

2025-11-07

How to generate and display personalized SEO titles, keywords, and descriptions for different pages using the universal TDK tag `tdk`?

In website operation, optimizing search engines (SEO) is a key link to obtaining natural traffic.And TDK (Title, Description, Keywords) as the first impression of the page presented in search engine results, its importance is self-evident.It not only affects the ranking of the website on the search results page, but also directly determines whether the user will click to enter your website.AnQiCMS knows the value of TDK for SEO and therefore provides a highly flexible and powerful universal TDK tag——`tdk`.

2025-11-07