As an experienced practitioner who deeply understands the operation of AnQiCMS, I know the core status of templates in website construction.A well-structured template that follows conventions can not only present content efficiently, but is also the foundation of website SEO and user experience.Below, I will elaborate on the basic conventions and file directory structure of AnQi CMS template making, hoping to provide strong support for your content creation and management on AnQiCMS.
Basic conventions for Anqi CMS template creation
All AnQi CMS template files are used uniformly.htmlas a file extension.These template files, as well as the stylesheets, JavaScript scripts, and images they depend on, have a clear storage location..htmlTemplate files must be placed in the root directory of the project/templateIn the folder. And all the static resources used by all templates, such as CSS, JS, images, etc., are stored centrally./public/static/Under the directory. This separation helps with code organization, and it is also convenient for managing static resources and CDN acceleration.
On the syntax level, AnQi CMS adopts a label marking method similar to the Django template engine, which is very friendly for developers familiar with MVC or MVT frameworks. Variable calls use double curly braces{{变量名}}Define, for example, if you need to display the article title, you can use it directly{{archive.Title}}. For conditional judgments, loop controls, and other logical operations, single curly braces and percentage signs are used, for example{% if 条件 %}...{% endif %}It should be noted that these logical tags are paired and must have corresponding end tags to close them, in order to ensure the integrity of the grammatical structure and avoid parsing errors.
The naming convention of variables also has a set of conventions, usually using camel case (CamelCase), where the first letter of each word is capitalized, for example{archive.Id}or{archive.Title}.This naming method improves the readability of the code and facilitates variable identification.In addition, the encoding format of the template file is unified as UTF-8.If the template file uses other encoding, it may cause the page to display garbled text, affecting user experience.Therefore, whether users editing template files in Windows or Linux environments, they should ensure that they are saved in UTF-8 encoding format.
The Anqi CMS template system also has high flexibility, supporting a variety of website display modes. You can choose to develop a set ofAdaptive templateAuto-adapt to different screen sizes; also can chooseCode adaptation templateProvide different HTML structures for different devices; or directly adoptPC + mobile phone independent site modeIndependent templates are provided for PC and mobile devices. When choosing the code adaptation mode or the PC + mobile terminal mode, a dedicated set of templates for the mobile terminal also needs to be created, and this set of mobile terminal templates should be stored in a folder namedmobileIn the subdirectory, its internal structure is similar to that of the PC template, to achieve special optimization for mobile devices.To further simplify template configuration, AnQiCMS also supports some default custom template names. If the template files with these specific names exist, the system can automatically apply them without any additional settings in the background.{模型table}/{文档id}.html, Document list template is{模型table}/list-{分类id}.html, Single page template ispage/{单页面id}.html, All of these greatly facilitate template development.
File directory structure of AnQi CMS template
Root directory of AnQi CMS template is/templateAll templates must be placed in this directory. For easy management, each independent template topic should be/templateBelow has its own exclusive directory. In this exclusive directory, a file namedconfig.jsonis indispensable, as it carries the basic information and configuration of the template.
config.jsonThe file is a template identity proof that includes the template name, package name, version number, description, author, homepage, creation time, template type (0 for adaptive, 1 for code adaptation, 2 for computer + mobile phone end) and enable status (0 for not enabled, 1 for in use).These fields are mostly optional, but reasonable completion can help us better manage and distinguish templates.statusfield to1It indicates that it is the currently used template.
Within the template directory, Anqi CMS provides two main file organization modes to adapt to different development habits and project requirements:
FirstlyFolder organization mode. In this mode, template files are categorized through multi-level directories, which is clear and easy for large-scale project management. For example, common header, footer code snippets are usually extracted tobash.htmlThe file is for global reference; reusable components such as sidebars, breadcrumbs, and others are stored inpartial/the catalog. The home page file is located inindex/index.html. Different content models (such as articles, products) have their own directories, for example, the document detail page can have{模型table}/detail.html, even for specific document IDs{模型table}/detail-{文档ID}.html; The document list page corresponds to{模型table}/list.htmlor{模型table}/list-{文档分类ID}.html.In addition, there are clear storage paths for comment list pages, online message pages, single-page detail pages, search pages, tag pages, and various error pages (404, 500, site closed).mobile/In the subdirectory.
Another one isFlat file organization modeIn this mode, files do not perform deep directory nesting, but are distinguished by the prefix of the filename to identify the page type. For example, the home page isindex.html, and the model home page is{模型table}_index.html, the document detail page is{模型table}_detail.htmlThis pattern is more convenient for small projects or developers who prefer flat structures. Like the folder mode, the directory structure and file naming of mobile template inmobile/The directory will also be consistent.
Regardless of the organizational model adopted, AnQi CMS provides high flexibility. For specific content pages, such as a specific single page (such as "About Us"), you can specify an independent template file in the background, such aspage/about.html.This single page can have a completely personalized display style without modifying the general template.This custom feature makes Anqi CMS excel in meeting diverse business needs.
Follow these templates and directory structures to ensure the stable operation of your secure CMS website and lay a solid foundation for future content updates, feature expansion, and team collaboration.A clear structure allows you to focus on creating and publishing high-quality content, truly unleashing the powerful value of Anqi CMS as an enterprise-level content management system.
Frequently Asked Questions (FAQ)
1. Why is my AnQiCMS website page displaying garbled text?Page garbling is usually caused by incorrect encoding of template files. Please ensure that all.htmlThe template files are saved in UTF-8 encoding format.You can check and re-save the file encoding in a code editor (such as VS Code, Sublime Text, etc.)
How to set up a separate template for mobile devices?If you have chosen the 'Code Adaptation' or 'PC + Mobile Independent Site' template type, you need to create a folder named in the current template directorymobile. In thismobileIn the directory, place the template file you designed for the mobile end according to the same directory structure and file naming conventions as the PC template.AnQiCMS will automatically load the corresponding template based on the type of device being accessed.
3. Do I support using different templates for specific articles or categories, AnQiCMS?download.html),Make sure that the file exists in your template design package, and the system will automatically apply it. You can also specify a standalone template in the same way for a single page.