As a senior security CMS website operator, I am fully aware of the importance of a high-quality, easy-to-maintain template for the successful operation of a website.The template is the facade of content display, which directly affects user experience and search engine optimization.In AnQiCMS, the creation of templates follows a series of basic conventions and strict file encoding requirements. These standards are designed to ensure the efficient operation of the system and the correct rendering of content.

Basic conventions for AnQiCMS template creation

The core of AnQiCMS template creation lies in its simple yet powerful conventions, which cover file structure, syntax, and naming standards, aiming to allow developers to quickly get started and create stable, flexible web interfaces.

Firstly, all template files of AnQiCMS are uniformly used.htmlAs file extensions. These template files are stored in the root directory of the system./templateThe content in the folder. To maintain the purity of the template file and facilitate management, the style files (CSS), JavaScript scripts (JS), and images, etc., as static resources involved in the template, need to be classified separately and stored./public/static/The directory. This separation design concept ensures that the content display logic is not interfered with static resources, improving loading efficiency and maintenance convenience.

AnQiCMS's template engine syntax is similar to Django template engine, and it also has a similar effect to Blade syntax, which makes it very easy for developers with relevant experience to master. Variable calls in template files are made using double curly braces{{变量}}The form presents the data transmitted from the backend to the frontend in a direct manner.iffor{% 标签 %}And these logical tags usually need to appear in pairs, for example{% if archive.Id == 10 %}这是文档ID为10的文档{% endif %}This clear syntax structure helps maintain the readability and logic of the template code.

In variable naming, AnQiCMS adopts the camel case naming convention (CamelCase), which means the first letter of each word is capitalized, for example,archive.Id/archive.TitleOf course, some special regulations or built-in variables may be exceptions, but following this general rule can greatly improve the consistency of the code.

AnQiCMS supports various website modes in templates, including adaptive template types, code-compatible template types, and independent site modes for PC and mobile. To better adapt to mobile device access, if code compatibility or PC+mobile mode is selected, the system also provides specificallymobileCatalog, used to store independent mobile template files, with the internal directory structure and file naming conventions consistent with the PC template.

In addition, AnQiCMS supports some default custom template names, which means that if the template files are named in a specific format and exist, the system will be able to automatically recognize and apply them without any additional configuration in the background. For example, the default custom template for documents can be named{模型table}/{文档id}.htmlEnglish, the default template for document lists is{模型table}/list-{分类id}.htmlEnglish, the default template for single pages ispage/{单页面id}.htmlThis intelligent recognition mechanism greatly simplifies the configuration process of templates, and also allows developers to create dedicated templates for specific pages or categories, such as creating a template for the "About Us" page.page/about.html,to achieve personalized content display.

The encoding requirements of AnQiCMS template files

For AnQiCMS template files, the encoding requirement is clear and non-negotiable: all template files must be uniformly encoded in UTF-8.

For Windows operating system users, it is particularly important to note this.When editing template files, make sure that your text editor or IDE has selected UTF-8 encoding format when saving files.Many editors may use GBK or other local encodings by default. If not manually adjusted, it is likely to cause encoding issues after uploading to the server.Strictly comply with UTF-8 encoding requirements is the basis to ensure the correct display of AnQiCMS website content and the stable operation of the system.


Common Questions and Answers (FAQ)

1. Why does AnQiCMS template file strictly require UTF-8 encoding? What if I use another encoding?

2. In AnQiCMS, each template set needs oneconfig.jsonfile? What is its main function?

Yes, in AnQiCMS, every independent template needs to include a file in its own template directory.config.jsonConfiguration file. This file mainly provides basic metadata for the template, such as the template name (name)、corresponding template folder name (package), version number (version)、brief description (description), and author information (author/homepage)、creation time (created)等。where,template_typefield is used to define the type of template (such as adaptive, code adaptation, PC+mobile), andstatusfield indicates the enable status of the template.config.jsonAllow AnQiCMS to recognize and manage the installed templates is the key to the normal operation and recognition by the system.

3. How does the 'Default Custom Template Name' supported by AnQiCMS templates work? How should I make use of it?

AnQiCMS's “Default Custom Template Name” is a convenient feature that allows you to create template files according to specific naming rules, so the system can automatically recognize and apply these templates without manually specifying them in the background. For example, you can create a file namedpage/{单页面id}.html