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.