AnQiCMS as a flexible and efficient content management system provides powerful template customization capabilities.It is crucial to fully utilize the 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 encountering them.

Firstly, AnQiCMS templates use.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 'headquarters' for AnQiCMS to recognize and load templates.

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

It is worth noting that the template file itself only contains structure and logic.The static resources such as CSS stylesheets, JavaScript scripts, images, etc., which are used in the template, are not placed directly in the template package folder./public/static/The content in the catalog. This separation helps to maintain the cleanliness of the template files and optimize the loading of static resources.

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

One isFolder organization modeIn this mode, template files are further divided into subfolders according to functionality or content type. For example, the home page template may be located inindex/index.html, the template for the article detail page may be located inarchive/detail.htmlThis structure is clear and convenient for managing large websites.

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

No matter which mode is used, AnQiCMS supports a set of standard file naming conventions so that the system can automatically recognize and apply them. For example,bash.htmlCommonly used to define common headers and footers,partial/The catalog stores reusable code snippets such as sidebars, breadcrumbs, etc. For specific content, AnQiCMS also supports more fine-grained template specification:

  • Model and category pages:You can define default templates for document detail pages, list pages, for example{模型table}/detail.htmlor{模型table}_detail.html。AnQiCMS even supports specifying templates for documents or categories with a specific ID, format as{模型table}/{文档id}.html(for document) or{模型table}/list-{分类id}.html(for list).
  • single page: For single-page pages such as "About Us", "Contact Us", they can havepage/detail.htmlAs the default template, it can also create a dedicated template for a specific single page (such as the page with ID 10)page/{单页面id}.html.
  • Error page: Commonerrors/404.htmlanderrors/500.htmlto display 404 and 500 error pages,errors/close.htmlUsed 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 a directory under the template package.mobileSubfolder, and then repeat the directory structure and file naming of the PC template according to one of the two patterns mentioned above.AnQiCMS will automatically load the corresponding mobile template according to the access device.

In addition to these agreements, you can also specify the template file manually in the background content management for specific categories, documents, or single pagesManually specify the template file。For example, if you create a special template for a document,download.htmljust set the template field to that template when editing the document in the background,download.htmlEnglish, AnQiCMS will load this file for rendering.

This flexible file extension and storage strategy, combined with clear naming conventions, make AnQiCMS 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.


Common Questions (FAQ)

  • Q1: In addition to the template file.htmlsuffix, does it support.tplor.twigand other suffixes?AnQiCMS的模板系统设计上是统一使用English.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, and all template files should be.htmlEnd.

  • 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 it?Yes, AnQiCMS supports this customization requirement.In addition to the default naming conventions of the system, you can also manually specify the template filename for specific content (such as categories, documents, or single pages).archive/vip_detail.htmlTemplate, and in the background set the "document template" field of the relevant VIP articlesvip_detail.html.

  • Q3: The CSS, JavaScript and images, etc. static resources used in the template, where are they placed in the directory, and how can they be correctly referenced in the template?/public/static/After 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 construct the correct URL. In most cases, you can directly use{% system with name="TemplateUrl" %}This tag is used to get the root path of static resources under the current template set, and then add your resource path after it, for example,<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">, or use a path like this,/static/img/logo.pngto refer to a relative root path.