AnQiCMS, its high efficiency and flexible customization features developed in Go language provide strong control for the display of website content.No matter if 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 website personalization and user experience.
Template file's basic structure and storage location
All related to the template.htmlFiles are stored centrally in/templateThe root directory. Typically, each independent template theme will have a dedicated subdirectory, for example, one nameddefaultThe template, all files will be located in/template/defaultIn 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 uses an adaptive, code adaptation, or a PC+mobile independent site mode.
Except.htmlTemplate file, static resources such as CSS styles, JavaScript scripts, and images related to the template will be stored uniformly in/public/static/In the directory, this can maintain the clarity and neatness of the project structure. When editing template files, make sure the file encoding is UTF-8 to avoid garbled characters on the page.
How AnQiCMS automatically identifies and matches templates
One of AnQiCMS' design philosophies is 'configuration by convention', which means that in many cases, the system will automatically match template files based on a set of preset naming rules, thus saving you the trouble of manually specifying them.
For example, for the homepage of the website, AnQiCMS will try to loadindex/index.html(in folder organization mode) or directly under the template root directoryindex.html(in flat mode).
For the list page and detail page, AnQiCMS's intelligent matching mechanism is more flexible:
- List page (category page)If you have an 'article' model, the system will first look for
article/list.htmlAs a general article list template. If you want a unique layout for a specific category (such as the "News Information" category with ID 10), 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.htmlIf you need a specific article (such as the 'Product Release' article with ID 25) to display a different style, you can createarticle/detail-25.html. - single page:For the 'About Us' type of standalone page, the default template might be
page/detail.html, while for the 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 it.
精细化控制:手动指定特定页面模板
Although the automatic matching feature of AnQiCMS is very convenient, under some complex scenarios, we may need to have more refined template control for individual pages.AnQiCMS provides the option to manually specify the template path for a specific page in the background, making personalized customization easily accessible.
全局共享模板片段: 在您的模板目录下,通常会有一个
bash.htmlFile, used to store the common header, footer, and other public area codes of the website. In addition,partial/The directory is often used to store reusable code snippets such as sidebars and breadcrumb navigation. Through{% include "partial/header.html" %}Such tags, you can easily introduce these shared contents on any page.Set an independent template for a single category: In AnQiCMS backend's 'Content Management' -> 'Document Category', when editing a category, you will see a 'Category Template' field. Here, you can fill in a completely custom template file path, for example, specify a named template file for your 'Industry Information' category.
article/industry-news-list.htmlThe template.Further more, you can also choose to "apply to subcategories", so that all subcategories under this category will inherit this template and achieve a unified style.article/news-detail.html.Specify a dedicated template for a single document: In AnQiCMS backend under "Content Management" -> "Publish Document" or edit document, there is a field called "Document Template" in the "Other Parameters". Suppose you have an article about "Download the latest product whitepaper", and you want it to have a unique detail page layout with a download button and customer cases, you can create a
article/whitepaper-download.htmlTemplate, and enter this path in this field. This will cause the specific article to load the specified template instead of the generic document detail template.Set a unique template for a single independent page: In 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 multi-department contact information, you can create a
page/contact-us.htmlThe template, and specify it in the background.
Through these flexible configuration methods, AnQiCMS ensures that you have absolute control over the display of every inch of content on the website.Whether it is following the system conventions or manually fine-tuning, it can make your website stand out in both visual and functional aspects.
Filling and dynamic display of 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.