In Auto CMS, template files are the basis for displaying website content.It is not just a simple HTML file, but a set of 'blueprints' that follow specific conventions and rules. Only by accurately adhering to these conventions can the system correctly parse, render, and display the structure of your website content.Understanding these basic conventions can help you customize and manage your website more efficiently, ensuring that content is presented to visitors in the way you expect.

The storage location and basic format of template files

Firstly, the Aiqi CMS has clear requirements for the storage location of template files. All template files should be placed uniformly under the root directory of the website./templateIn the folder. Each independent template needs to be in this/templateCreate your own exclusive folder under the directory and include aconfig.jsonConfiguration file, this file is like the 'ID card' of the template, explaining to the system the name, version, author, and most importantly—the template type and enabled status.

The template file itself is also very intuitive, they are all named with.htmlas a file extension. As for the CSS styles, JavaScript scripts and images, etc., static resources that will be used in the template, they need to be stored separately./public/static/The directory structure, this can keep the template directory neat, and is also beneficial for website performance optimization.

Additionally, a seemingly minor but crucial detail is the file encoding. All template files must be uniformly adoptedUTF-8 encoding.If the page content uses other encoding formats, it is very likely to appear garbled, resulting in the inability to display normally.For users editing templates using the Windows system, be sure to save the file in UTF-8 format when saving.

AnQi CMS template engine and syntax

The template core of Anqi CMS adopts a syntax similar to Django template engine, which allows developers familiar with Blade template or similar syntaxes to quickly get started.

The reference to data variables is very direct, you just need to enclose the variable name in double curly braces, for example{{变量名}}。The system will automatically fill in the corresponding data into these positions based on the context of the current page.

For more complex logic control, such as conditional judgments,if), loop traversal (for)等,则需要使用单花括号和百分号来定义标签,例如{% if 条件 %}。值得注意的是,这些逻辑标签通常都需要一个对应的结束标签,比如{% endif %}or{% endfor %}Forming a paired structure to ensure the integrity of the logic block.On variable naming, Anqi CMS recommends using CamelCase naming conventions, that is, the first letter of each word is capitalized, which helps improve the readability and consistency of the code.

The type of template and refined organization

The Auto CMS provides various template types to meet different website requirements, including responsive templates, code adaptation templates, and PC+mobile independent site modes. This isconfig.jsonin the filetemplate_typeField settings. If you choose code adaptation or PC+mobile independent mode, and you want to provide an independent template for mobile devices, then you need to create a directory namedmobileThe subdirectory, and store the mobile template files in a structure similar to that of the PC template.

On file organization, Anqi CMS provides two main modes: folder organization mode and flat file organization mode.No matter which mode, the system has preset some default template file names. As long as these files exist in your template directory, the system can automatically apply them without any separate settings in the background.

For example:

  • Home page of the websiteIt is usuallyindex/index.htmlorindex.html.
  • Content model home page(such as article list page or product list page) can be{模型table}/index.htmlor{模型table}_index.html.
  • Document details page(such as a single article or product details) can be{模型table}/detail.htmlor{模型table}_detail.html.
  • Category list pagethen{模型table}/list.htmlor{模型table}_list.html.
  • Single Page Detail Pagesuch as pages like "About Us", can bepage/detail.htmlorpage.html.

The more powerful one is, that AnQi CMS supports the use of custom templates for specific content items.This means you can specify a completely independent template file for a specific document ID, category ID, or single page ID.article/10.htmltemplate; or create a single page for "About Us"page/about.htmlThe template, and configure the page to call this custom template in the background. This flexibility allows the presentation of website content to be highly personalized.

Intelligent mapping of content to the template

Understood these conventions, you will find that the CMS is very intelligent in combining backend data with frontend templates.When a visitor requests a page, AutoCMS will automatically locate and render the most suitable template file based on the URL, backend configuration, and the current directory structure of the template, while passing related data (such as article titles, content, category information, etc.) to the template through predefined tags and variables.

For example, on the document detail page, you can use{{archive.Title}}to get the article title, use{% archiveDetail with name="Content" %}to display the article content; on the category list page, you can use{% categoryList categories with moduleId="1" %}to iterate over the article categories, and use{% for item in categories %}These built-in tags and variables greatly simplify the interaction process between content and templates, allowing you to focus on content creation and page design.

Summary

The template file conventions of Anqi CMS, aiming to provide a standardized and flexible framework.By placing files in the correct location, using unified encoding, adhering to template syntax similar to Django, and making good use of its various template types and custom naming mechanisms, you will be able to fully utilize the powerful functions of the Aanqi CMS to build a website with clear structure, rich content, and strong visual appeal.Familiarize and apply these basic conventions is the key step to efficiently operate your CMS website.


Common Questions (FAQ)

1. My website template shows garbled text, what is the cause of this?If your website template displays garbled text, the most common reason is that the encoding format of the template file is incorrect.AutoCMS requires all template files to be encoded in UTF-8..htmlFile, make sure they are saved in UTF-8 format. If you are using the Windows system, pay special attention to select the UTF-8 encoding option when saving files.

2. I have set a custom template for a category or document in the background, but it didn't work when accessed from the front end. Why is that?There may be several reasons for this situation:

  • Template file does not exist or path is incorrect:Please ensure that you have created the corresponding custom template file in the template directory, and the file name and path are exactly the same as those set in the background. For example, if the background is set todownload.html,then the file should be in the root directory of the current template, rather than in some sub-folder, or if set toarticle/download.html,the file should be intemplate/您的模板名称/article/download.html.
  • Template type does not match:Checkconfig.jsonoftemplate_typeDoes it match your actual website requirements (such as PC + mobile independent mode)? If it is a mobile template, are the files placed inmobilethe directory.
  • Cache issue:Attempt to clear the system cache of the Anqi CMS, sometimes the cache can cause the newly set template to not take effect immediately.

3. How does the Safe CMS identify which template file should be used for my website's homepage, article detail page, or category list page?auto through a set of intelligent matching rules to identify.Firstly, it will judge the current page as the homepage, article detail, category list, or other type based on the structure of your website URL.index.htmlRepresents the homepage,{模型table}/detail.htmlRepresents document detail,{模型table}/list.htmlRepresents a list of categories. If you are in the background for a specific content item (such as a category or document ID