What are the requirements for the `.html` suffix and `/template` directory structure of the template file in terms of content display?

Calendar 👁️ 87

In AnQiCMS, whether the content can be presented correctly and elegantly to the user largely depends on the organization and naming conventions of the template files.Understand these basic conventions, which can help you design and manage website interfaces more efficiently, ensuring the accurate presentation of content.

The cornerstone of the template file:/templateTable of contents and.htmlsuffix

AnQiCMS has clear regulations for the placement of template files: all template files must be stored in the root directory of the website./templateIn the folder. This directory is the only entry point for AnQiCMS to find and load templates. At the same time, template files are uniformly used.htmlAs a suffix, this is not only the mark of the system recognizing the template, but also conforms to the general habits of front-end development.

When you create or edit a template file, you also need to pay special attention to the file encoding.AnQiCMS requires template files to be encoded in UTF-8.If the page is displayed in a different encoding format, it is very likely to appear garbled, which will affect the user experience.For users accustomed to editing in the Windows environment, it is necessary to select UTF-8 format when saving.

In addition, the static resources such as CSS stylesheets, JavaScript scripts, and images required by the template should not be placed directly in/templateIn the directory. AnQiCMS provides a special place for storing these static resources./public/static/Directory. Separating static resources from template files helps improve the loading efficiency and maintenance convenience of the website.

Flexible organization methods: folder mode and flat mode

AnQiCMS provides two main template organization modes to meet the needs of websites of different scales and complexities:

  1. Folder organization mode:This pattern categorizes templates by creating subfolders, making the structure clear and easy to manage large projects. For example, the homepage template may be locatedindex/index.html, and the article detail page template may be locatedarticle/detail.html, the product list page template is locatedproduct/list.html. Common code snippets for some pages, such as website headers (header), footers (footer), or sidebars (sidebar), are usually stored inpartial/In the catalog and pass throughincludeLabel at the required location for reference, to achieve code reuse. This hierarchical structure allows developers to quickly locate and modify specific function templates, greatly enhancing maintenance efficiency.

  2. Flattened file organization mode:For websites with relatively simple structures and a small number of pages, a flat model may be more convenient.In this mode, most template files are directly stored in the root directory of the template, and are distinguished by a naming convention for different types of pages.For example, the home page template might beindex.htmlArticle detail page template isarticle_detail.htmlProduct list page template isproduct_list.htmlThis pattern reduces the directory level, making the files clear at a glance, suitable for rapid development and lightweight maintenance.

No matter which mode you choose, the key is to maintain consistency and follow the naming conventions of AnQiCMS.Because the system will automatically match the content with the template according to these conventions, ensuring the correct display of the content.

Considerations for mobile-endmobile/Table of contents

With the popularization of mobile Internet, responsive design or independent mobile pages are becoming more and more important.AnQiCMS took this into consideration and provided good support for mobile templates.

If your website chooses to use the template type 'Code Adaptation' or 'Computer + Separate Mobile Site', AnQiCMS will look for a folder namedmobile/in your template folder. Thismobile/The internal structure and file naming rules of the directory are consistent with the main template directory (PC end). This means that if you have aarticle/detail.htmlUsed for PC end article details, then the corresponding mobile end article detail template should be placedmobile/article/detail.html. Thus, AnQiCMS can automatically load and display the corresponding template according to the type of device accessed, providing a ** browsing experience for users of different devices.

The template's 'ID':config.json

Every set of AnQiCMS template needs an 'ID'——which is under the template directoryconfig.jsonThe file. This file contains the basic information of the template, allowing AnQiCMS to identify and manage this template correctly.

config.jsonIt contains some important fields:

  • nameTemplate display name, convenient for you to select and identify the template in the background.
  • packageTemplate folder name, usually a combination of letters and numbers, serving as the unique identifier for the template.
  • versionThe version number of the template, convenient for tracking and updating.
  • template_typeThis is a key field that defines the type of the template. For example,0Represents an adaptive template (a set of templates that adapt to all devices),1Represents code adaptation (requires an independent mobile directory),2Represents an independent computer + mobile site.
  • status: Indicates the enabled status of the template,0is disabled,1In use. Only one template can be used in all templates.statusThe value of1The template is enabled.

Byconfig.json,AnQiCMS not only understands the basic properties of templates, but can also switch templates and adapt functions accordingly.

Intelligent matching: preset template name

AnQiCMS is another convenient feature as it intelligently recognizes certain pages.If you create a template file following the system's predefined naming rules, AnQiCMS can still automatically apply these templates even if it is not manually set in the background.This greatly simplifies the template configuration process.

Some common preset template names include:

  • Document Details Page: {模型table}/{文档id}.htmlor{模型table}/detail.htmlFor example,article/123.htmlIt will match the article with ID 123, whilearticle/detail.htmlIt will be the default detail page template for all articles.
  • Document List Page: {模型table}/list-{分类id}.htmlor{模型table}/list.htmlFor example,product/list-45.htmlIt will match the product category list with ID 45, whileproduct/list.htmlis the default list template for all product categories.
  • Single page detail page: page/{单页面id}.htmlorpage/detail.htmlFor example,page/about-us.htmlCan be used as the exclusive template for the "About Us" page.

This intelligent matching mechanism provides a certain flexibility. You can create customized template files for specific documents, categories, or single pages without changing the templates of other general pages.If you have a name calledabout.htmlThe single page template, just specify the template of this page in the single page management of the backgroundpage/about.htmland the system will automatically load it.


In summary, the template file naming and directory structure of AnQiCMS is the core of its content display mechanism. By placing all template files in a/templatedirectory and using.htmlFile extension and UTF-8 encoding can ensure that the system correctly identifies and parses. At the same time, choose the folder organization or flat organization mode according to the scale of the website, cooperate withmobile/Directory processing for mobile display, as well asconfig.jsonFile management template metadata, capable of achieving efficient template development and maintenance.The intelligent recognition function of the system for preset template names further enhances the convenience and flexibility of content matching with templates.Master these conventions, and your AnQiCMS website will be presented to visitors in the most ideal way.


Frequently Asked Questions (FAQ)

1. If my template file is not/templatein the directory, or the file extension is not.html, can AnQiCMS still display the content normally?You can not. AnQiCMS strictly requires that template files must be stored in/templatethe directory, and.htmlAs a file extension, otherwise the system will not be able to recognize and load these templates, which may cause the content to be displayed abnormally, even leading to page errors.

2. How does AnQiCMS decide which template to use for a specific page (such as an article or product detail page)?AnQiCMS will decide based on a set of priority rules.Firstly, it will check if a custom template is specified for the article, category, or single page in the background.If not, it will try to find a preset template file that matches the content model, category ID, or single page ID (such asarticle/detail.htmlorproduct/list-123.html)。Finally, if none of the above rules match, the system will fallback to the default generic template.

3. Can I use folder organization mode and flattened file organization mode at the same time in a template theme?In technical terms, you can mix these two modes under a template theme because AnQiCMS will look for files according to the agreed path. However, in order to maintain the consistency and maintainability of the template structure, as well as to avoid potential file naming conflicts or confusion, it is strongly recommended that you...

Related articles

How does AnQiCMS ensure the compliance and security of displayed content through security mechanisms?

In today's digital age, the security and compliance of website content are the core challenges faced by operators.Users expect to browse safe and harmless information, search engines favor high-quality compliant content, and various regulations also have strict requirements for the dissemination of online information.As a system dedicated to providing an efficient and customizable content management solution, AnQiCMS has integrated content security mechanisms and compliance guarantees into its core functions from the very beginning, striving to build a stable and reliable content publishing platform for users.AnQiCMS ensures the journey of display content compliance and security

2025-11-07

How static caching and SEO optimization can improve the loading speed and search engine friendliness of website content?

The loading speed of website content and search engine-friendliness are the two indispensable cornerstones of modern website operations.They not only directly affect user experience, but are also key factors in determining the ranking of a website in search engines.As a content management system, AnQiCMS (AnQi CMS) took these two points into full consideration from the beginning of its design, providing strong support for operators through static caching and a series of SEO optimization tools.Static caching: The unsung hero of website acceleration

2025-11-07

How does the flexible permission control mechanism ensure the operation safety of different administrators for content display?

How to ensure that your content operations are both secure and flexible in AnQi CMS?Today, with the rapid explosion of digital content, efficient and secure content management has become the cornerstone of corporate operations.For those who have multiple brand websites, content teams, or self-media operators, how to ensure that different team members work safely and efficiently within their respective responsibilities while avoiding misoperation or abuse of privileges is a major challenge for content management systems.

2025-11-07

How does the modular design of AnQiCMS support the secondary development and expansion of the content display function?

AnQiCMS demonstrates high flexibility and strong support capabilities in the secondary development and expansion of its content display function, mainly due to its ingenious modular design and rich built-in tools.For users who want to build personalized websites, understanding these mechanisms is crucial.Firstly, the flexible content model of Anqi CMS is the foundation for customizing all content display.The system does not simply preset a few content types, but allows users to customize various content models according to actual business needs, such as in addition to articles and products

2025-11-07

How to control content conditional judgment and loop display in AnQiCMS with Django template engine syntax?

## How to cleverly use Django template syntax: Make AnQiCMS content display more flexible conditional judgment and loop The strength of AnQiCMS not only lies in its efficient and stable backend architecture, but also in the great flexibility it provides for content operators in front-end content display.Among them, deeply integrating the Django template engine syntax allows us to build like a child's blocks, easily control the presentation of website content through simple conditional judgments and loops, creating more intelligent and user-friendly dynamic pages.This article, let's delve into it together

2025-11-07

How does AnQiCMS handle template files with different encoding formats to avoid garbled content display?

One of the most annoying problems when using a website content management system is the display of garbled characters, especially when the website involves multiple languages or imports content from different sources.This chaos not only affects user experience, but may also damage the professional image of the website.AnQiCMS is a system dedicated to providing an efficient and customizable content management solution, with a clear strategy for handling template file encoding, aiming to help users eliminate乱码 from the root.The core lies in AnQiCMS's unified requirements for **UTF-8 encoding**. UTF-8

2025-11-07

How does the adaptive template, code adaptation, and PC + mobile mode affect the display of content on different devices?

AnQiCMS content management system provides powerful flexibility in content presentation, especially for display effects on different devices.It supports three template modes of "adaptive", "code adaptation", and "PC + independent mobile site", allowing us to finely control the display of content on computers, tablets, and mobile phones according to specific needs.Understanding the working principle of these patterns is crucial for ensuring user experience and optimizing website performance.First, let's understand **Adaptive Mode**.In adaptive mode, the website uses a set of templates and styles

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