How are the basic conventions and file directory structure requirements for template creation in AnQi CMS?

Calendar 👁️ 69

As an experienced security CMS website operation person, I know that a clear and standardized template making convention and directory structure is crucial for the long-term operation and maintenance of the website.A high-quality template not only improves user experience, but also is the foundation of SEO optimization.Next, I will elaborate on the basic conventions and file directory structure requirements of the Anqi CMS documentation for you.


Basic conventions and file directory structure requirements for AnQi CMS template creation

In Anqi CMS, template creation requires adherence to a series of basic conventions to ensure compatibility, maintainability, and efficient operation.These conventions cover file naming, encoding, syntax, and static resource management, etc.

Anqi CMS template files are unified in use.htmlAs a file suffix, and stored centrally in the system/templateIn the directory.In order to avoid garbled characters on the page, all template files must use UTF-8 encoding format.For Windows users, when editing template files, it is necessary to save the file in UTF-8 encoding.

The syntax of the template engine is similar to the Django template engine, so developers familiar with similar syntaxes like Blade will find it very easy to get started. In the template, variable definitions use double curly braces, for example{{变量名}}However, logical tags such as condition judgment and loop control are defined using single curly braces and percent signs, for example{% if 条件 %}这是条件为真的内容{% endif %}.It should be noted that these logical tags are usually paired and need corresponding end tags.{archive.Id}or{archive.Title}Of course, there are also some special regulations that are exceptions.

The style sheets (CSS), JavaScript scripts, and images, etc., used in the template should be stored independently./public/static/Under the directory, separated from the template file, to keep the project structure clear and easy to manage.

AnQi CMS supports various template types, including adaptive templates, code adaptation templates, and PC + mobile independent site mode. To better adapt to mobile device access, if code adaptation mode or PC + mobile independent site mode is selected, a template named must be created in the template directory.mobileThe subdirectory is used to store dedicated template files for mobile devices, and its internal directory structure and template file naming are consistent with the PC template.

In template creation, Anqi CMS also supports some default custom template names. As long as the template files with these specific names exist, the system can automatically apply them without any additional settings in the background. For example, the default custom template name format for documents is{模型table}/{文档id}.htmlThe default custom template name format for the document list is{模型table}/list-{分类id}.htmlAnd the default custom template name format for the single page ispage/{单页面id}.html.

The file directory structure requirements for the template

The template root directory of Anqi CMS is/template. Each independent template must create its own dedicated directory under this root directory and include aconfig.jsonConfiguration file. This configuration file is the identity identifier of the template, which informs the system of all the basic information of the template.

config.jsonThe content of the file is as follows, all fields are optional, and if not filled in, the system will generate default values according to the actual situation:

{
	"name": "默认模板",
	"package": "default",
	"version": "1.0",
	"description": "系统默认模板",
	"author": "kandaoni.com",
	"homepage": "https://www.kandaoni.com",
	"created": "2022-05-10 22:29:00",
	"template_type": 0,
	"status": 0,
}

The field descriptions include:name(The name of the template),package(Template folder name, only supports letters and numbers),version(Template version),description(Template description),author(Template author),homepage(Author's website),created(Creation time),template_type(Template type, 0 for adaptive, 1 for code adaptation, 2 for computer + mobile mode), as well asstatus(Template usage status, 0 for disabled, 1 for in use). It must be emphasized that in all templates, only one set of templates can be used.statusThe value is set to 1, meaning only one template can be enabled at a time.

On the organization of template files, Anqi CMS provides two main modes: folder organization mode and flattened file organization mode.

Folder organization mode

In this mode, template files are organized into different subdirectories according to their functions.

  • bash.html: Usually stores common code snippets such as headers and footers for inheritance and reference by other pages.
  • partial/This is used to store reusable code snippets for sidebars, breadcrumbs, and so on.
  • index/index.htmlThis is the home page template of the website.
  • {模型table}/index.htmlThis is the home page of a specific content model.
  • {模型table}/detail.htmlThis is a general document detail page, or{模型table}/detail-{文档ID}.htmlCustom detail page for specific document.
  • {模型table}/list.html: General document list page, or{模型table}/list-{文档分类ID}.htmlCustom list page for specific category.
  • comment/list.html: Comment list page.
  • guestbook/index.html: Online message page.
  • page/detail.html: General single-page detail page, orpage/detail-{单页ID}.htmlCustom detail page for a specific single page.
  • search/index.html: Search results page.
  • tag/index.html: Tag homepage.
  • tag/list.html: Tag document list page.
  • errors/404.html: 404 error page.
  • errors/500.html: 500 error page.
  • errors/close.html: Site closed notification page.
  • mobile/If mobile template is enabled, this directory will store mobile template files consistent with the above structure.

Flat file organization mode

This

Related articles

How to configure contact information and customize system global parameters in Anqi CMS backend?

As an expert in the operation of Anqi CMS, I understand that high-quality content cannot be separated from a stable backend configuration as a support.The contact information of the website and global system parameters, although it seems basic, is the key to user trust, brand image, and the normal operation of the website's functions.Now, I will elaborate on how to configure these important information on the Anqi CMS backend.

2025-11-06

How to configure the automatic image processing (WebP, compression, thumbnails) in the content settings of AnQi CMS?

As a person who is deeply familiar with AnQi CMS and proficient in website content operation, I am well aware of the importance of image optimization for website performance, user experience, and search engine ranking.AnQi CMS provides a series of powerful automatic image processing features that can help operators efficiently manage and optimize website image resources.Below, I will give a detailed introduction on how to configure the automatic image processing in the content settings of Anqi CMS, including WebP conversion, image compression, and thumbnail generation.

2025-11-06

How does the navigation setting in AnQi CMS support multi-level menus and custom navigation categories?

As a website operator who deeply understands the operation of AnQiCMS, I am well aware of the importance of an efficient and flexible navigation system for website user experience and content presentation.The AnQi CMS provides great convenience and powerful content organization capabilities to website operators through its multi-level menu support and custom navigation category features.

2025-11-06

How to manage single pages and page resources (images, videos) in Anqi CMS?

As an experienced CMS website operation personnel, I know the importance of efficient content management for the success of the website.Whether it is a single page carrying the brand story or the images and video resources that constitute the visual experience, they are all core elements that attract and retain users.The Anqi CMS provides powerful and intuitive tools for fine-grained management of these contents, ensuring that the website is always presented in a **status to the audience.

2025-11-06

How to use the `archiveList` tag in AnQi CMS template to call the document list?

As an expert who has been deeply involved in the field of CMS content operation for a long time, I fully understand the importance of a flexible and efficient template tag for website content display.Among them, the `archiveList` tag is undoubtedly the core tool for calling document lists in the Anqi CMS template.It can not only help us accurately filter and display various types of document content, but also combine multiple parameters to meet the diverse needs of content presentation, thus providing readers with a high-quality browsing experience.

2025-11-06

How to use the `categoryDetail` tag to get category details in the AnQi CMS template?

Hello, I am your familiar old friend, a website operator who has been dealing with AnQiCMS for a long time.In daily content management and website optimization work, flexibly using AnQiCMS template tags is the key to improving efficiency and user experience.Today, let's delve deeply into a very practical tag: `categoryDetail`, and see how it helps us obtain detailed category information in the AnQiCMS template.

2025-11-06

How to use the `tagDataList` tag to display documents under a specified Tag in the AnQi CMS template?

As an experienced CMS website operations manager for a leading security company, I know that high-quality content and convenient user experience are the key to attracting and retaining users.Tags (Tag) serve as an important dimension for content organization, not only helping users quickly find the content they are interested in, but also an indispensable part of internal link optimization and SEO strategy.

2025-11-06

How to use `for` loop and `if` conditional judgment tags in Anqi CMS template?

As an experienced Anqi CMS website operation personnel, I am very clear about the core role of templates in content presentation.A flexible and efficient template can not only enhance the user experience but also help us achieve accurate content placement and management.In the Anqi CMS template system, the `for` loop and `if` conditional judgment tags are the two cornerstones for building dynamic and interactive web pages.They make content no longer static text blocks, but can intelligently display according to data changes.

2025-11-06