As a website operator who is well-versed in the operation of AnQiCMS, I am well aware that the foundation of content presentation lies in its flexible and standardized template system.A deep understanding of AnQiCMS template file structure and naming conventions is crucial for efficient management of website content, achieving personalized display, and ensuring system stability.The following will elaborate on the template design principles of AnQiCMS.
The AnQiCMS template system aims to provide high levels of customization and ease of use.The core lies in a clear directory structure and a set of Django-style template syntax./templateIn the folder. Each independent template theme, or a complete website skin, will have its own dedicated subdirectory, for example/template/defaultThis subdirectory of the topic must contain, in addition to template files, oneconfig.jsonconfiguration file.
config.jsonThe file is an important basis for AnQiCMS to recognize and manage templates, which contains metadata of the template. For example,nameThe field defines the display name of the template,packageSpecified the name of the template folder,versionMarked the version number,descriptionProvided a brief description,authorandhomepageAlso indicated the author and their website. In addition,createdRecorded the template creation time,template_type[en] (Optional values: 0 Auto-adaptive, 1 Code adaptation, 2 Computer + Mobile) Defines the response mode of the template, andstatus[en] The value indicates the current enabled status of the template. It is important to note that only one template can be in use at a time.
In terms of template file suffixes, AnQiCMS uniformly adopts.html. The template syntax is deeply influenced by the Django template engine, and variable calls use double curly braces, for example{{变量}}The conditional judgment, loop control, and other logical tags are in the form of a single curly brace combined with a percent sign, for example{% if 条件 %}...{% endif %}These tags must appear in pairs, with clear start and end tags. All template files must use UTF-8 encoding to avoid compatibility issues such as page garbled text.
AnQiCMS supports various website modes in template design to adapt to different terminal devices.This includes adaptive templates, code adaptation templates, and PC+mobile independent site mode.mobile/The subdirectory for storing exclusive template files for mobile devices.mobile/The file structure and naming conventions within the directory are consistent with the PC template.
AnQiCMS provides two main template file organization modes:
Folder organization mode is a recommended, structured way, which categorizes template files through multiple directories:
At the top level,bash.htmlThis is typically used to store public code snippets for websites, such as headers and footers, which can be referenced in other templates.partial/The catalog is specifically used to store smaller code snippets, such as sidebars, breadcrumb navigation, etc. The homepage of a website is usually composed ofindex/index.htmlDefine it. For different content models (such as articles, products), there will be corresponding home page templates, which are named in the format of{模型table}/index.html. The common template for content detail pages is{模型table}/detail.html[en] Also, you can create a dedicated template for documents with a specific ID, such as{模型table}/detail-{文档ID}.html[en]. Similarly, the content list page has{模型table}/list.html[en] and ones for specific categories,{模型table}/list-{分类ID}.html[en]. Other functional pages includecomment/list.html[en] (comment list),guestbook/index.html(Online Message),page/detail.html(Single Page Details), as well as for specific single page IDspage/detail-{单页ID}.html. The search page issearch/index.html, and the tab page hastag/index.htmlandtag/list.html. Error pages likeerrors/404.html/errors/500.htmlAs well as the site shutdown prompt pageerrors/close.htmlalso follows this pattern.
Flattened file organization mode is more concise, placing most template files directly under the theme root directory, distinguishing different types of pages through underscores in the file names:
Common codebash.htmlAnd the code snippet directorypartial/has the same usage as the folder organization mode. The homepage is namedindex.html. The model homepage uses{模型table}_index.htmlformat (for examplearticle_index.html). The content detail page and list page correspond to{模型table}_detail.htmland{模型table}_list.html【en】Other functional pages such ascomment_list.html/guestbook.html/page.html(Single page details, can also be)page-{单页ID}.html),search.html/tag_index.html/tag_list.htmland error pages.errors_404.html/errors_500.html/errors_close.htmlAll use flattened naming.
An