AnQiCMS as a flexible and efficient content management system provides powerful template customization capabilities.It is crucial to make full use of this advantage of AnQiCMS and understand the suffix and storage location of its template files.This can not only help you design websites more efficiently, but also locate and solve problems faster when encountered.

Firstly, AnQiCMS template files are unified using.htmlas a suffix. This means that all template files you create or edit should be saved in HTML format. These.htmlare stored in the root directory of the website./templatein the folder./templateThis is the 'home base' for AnQiCMS to recognize and load templates.

To better manage templates of different themes or styles, AnQiCMS allows you to create independent template sets. Each template set is located/templateA directory has its own exclusive subfolder, such as/template/default(System default template) or one customized by you/template/my_custom_theme. Each suite folder internally needs to contain aconfig.jsonA file used to describe the basic information of this template set, such as the template name, version, author, and the types of websites it supports (adaptive, code adaptation, or PC + mobile independent site).

It is noteworthy that the template file itself only contains structure and logic.And the stylesheets (CSS), JavaScript scripts, images, and other static resources used in the template will not be placed directly in the template kit folder.They are managed uniformly in the root directory of the website/public/static/In the catalog. This separation helps keep the template file tidy and optimize the loading of static resources.

AnQiCMS provides two modes for organizing template files to accommodate the habits of different developers:

One isFolder organization modeIn this mode, template files are further subdivided into subfolders by function or content type. For example, the home page template may be locatedindex/index.html, and the article detail page template may be locatedarchive/detail.htmlThis kind of structure is clear, convenient for managing large websites.

Another one isFlat file organization mode. As the name implies, in this mode, most commonly used template files are placed directly in the root directory of the template suite, distinguished by filenames, for example, the home page template isindex.html, the article detail page isarchive_detail.htmlThis approach may be more concise for small websites or personal blogs.

Regardless of the mode used, AnQiCMS supports a set of standard file naming conventions to facilitate automatic recognition and application by the system. For example,bash.htmlCommonly used to define the common header and footer,partial/The catalog stores reusable code snippets such as sidebars and breadcrumbs. AnQiCMS also supports more precise template specification for specific content:

  • Model and category pageYou can define default templates for document detail pages and list pages, for example{模型table}/detail.htmlor{模型table}_detail.htmlAnQiCMS even supports specifying templates for documents or categories with a specific ID, formatted as{模型table}/{文档id}.html(for documents) or{模型table}/list-{分类id}.html(For lists).
  • single page: For single-page items like "About Us" and "Contact Us", there can bepage/detail.htmlAs a default template, it can also create specific single pages (such as pages with ID 10).page/{单页面id}.htmltemplate for exclusive use.
  • error page: commonerrors/404.htmlanderrors/500.htmlused to display 404 and 500 error pages,errors/close.htmland is used for the prompt page when the website is closed.
  • Mobile templateIf your website needs to support an independent mobile site or code adaptation, just create one in the template package directorymobileSubfolder, and repeat the directory structure and file naming of the PC template according to one of the two modes mentioned above.AnQiCMS will automatically load the corresponding mobile template based on the visiting device.

In addition to these agreements, you can also specify a template file for a specific category, document, or single page in the background content managementManually specify the template fileFor example, if you create a specialdownload.htmltemplate, just set the template field to the document when editing it in the backgrounddownload.html,AnQiCMS will load the file for rendering.

This flexible file extension and storage strategy, combined with clear naming conventions, makes AnQiCMS's template system both powerful and easy to manage.It ensures website performance, while giving developers great freedom to customize the interface, meeting diverse display needs.


Frequently Asked Questions (FAQ)

  • Q1: Besides the template file,.htmlDo you support suffixes such as.tplor.twigand other suffixes?AnQiCMS's template system is designed to be unified using.htmlAs a template file suffix. Although its syntax is similar to the Django template engine, it is recommended to follow this convention to maintain system consistency and ease of use, all template files should be extended with.html.

  • Q2: If I want to load different templates for the same page (such as article detail page) based on different conditions (such as user role or article type), does AnQiCMS support this?Yes, AnQiCMS supports this customization requirement. In addition to the system default naming conventions, you can also manually specify the template file name for specific content (such as categories, documents, or single pages) in the background.For example, you can create content for VIP usersarchive/vip_detail.htmlTemplate, and set the 'Document Template' field of related VIP articles in the backgroundvip_detail.html.

  • Q3: Where are the static resources such as CSS, JavaScript, and images placed in the template?/public/static/After placing them in the directory, how can you correctly reference them in the template?When referencing these static resources in the template, you can use relative paths or combine system tags to build the correct URL. In most cases, you can use them directly.{% system with name="TemplateUrl" %}This tag is used to obtain the root path of static resources under the current template suite, and then add your resource path after it, for example<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">Or use a similar/static/img/logo.pngto refer to such a relative root path.