What are the basic conventions and directory structure specifications for AnqiCMS template creation?

Calendar 👁️ 70

Hello! As an experienced AnQiCMS website operator, I am very happy to share with you the key knowledge about AnQiCMS template creation.In my daily work, reasonable planning and precise application of templates are the foundation for ensuring efficient content display and enhancing user experience.A deep understanding of the basic conventions and directory structure specifications of AnQiCMS templates not only allows us to create and publish content more smoothly, but also lays a solid foundation for the long-term maintenance and optimization of the website.

Next, I will elaborate on the basic conventions and directory structure specifications followed by AnQiCMS template creation, helping you better master this powerful tool.

Basic conventions for AnQiCMS template creation

Build and customize templates in AnQiCMS, which requires adhering to a series of clear conventions to ensure the system can correctly parse and render your design.These conventions cover a wide range of aspects, including file formats, naming conventions, and template engine syntax.

Firstly, all template files are统一使用.htmlAs file extensions, and centrally stored in the root directory of the website./templateIn the folder. To maintain the purity and ease of management of the template file, the style sheets, JavaScript scripts, and static resources such as images that the template depends on should be stored independently./public/static/The directory, not mixed into the template file directory inside.

On template writing, AnQiCMS adopts syntax similar to Django template engine. This means you will use double curly braces to define and output variables, for example{{变量}}For more complex logic control, such as conditional judgment and loop traversal, use labels enclosed in single curly braces and percent signs, for example{% if 条件 %}These control flow tags usually need to appear in pairs, for example{% if ... %}Need corresponding{% endif %}To end.

Variable naming also has its rules. In the AnQiCMS template, variable names usually follow the camel case naming convention, and the first letter of each word must be capitalized.For example, you will seearchive.Id/archive.TitleVariables in the form of,IdandTitleThis naming convention starts with an uppercase letter. This helps to maintain consistency and readability in the code.

Moreover, the encoding format of the template file is crucial. AnQiCMS requires all template files to use UTF-8 encoding uniformly.If the template file uses a different encoding format, the page may display乱码when displayed, causing the content to be presented abnormally.Therefore, if you are editing template files in a Windows environment, please make sure to select UTF-8 encoding when saving.

AnQiCMS also supports various template types to adapt to different website designs and access needs.This includes adaptive template types, code adaptation template types, as well as independent templates for PC and mobile phones.When you choose the code adaptation mode or the PC + mobile end mode, the system allows you to design a separate template for mobile devices separately.These mobile templates need to be stored in the main template directory.mobileIn the subdirectory, and the internal directory structure and file naming rules are consistent with the PC template.

To further improve the flexibility and convenience of the template, AnQiCMS also supports some default custom template names.This means that as long as you create these template files following a specific naming format, the system can automatically identify and apply them without any additional configuration in the background.For example, the default custom template for the document can be named{模型table}/{文档id}.htmlThe default template for the document list is{模型table}/list-{分类id}.htmlAnd the default template for a single page ispage/{单页面id}.htmlThis mechanism greatly simplifies the process of designing personalized templates for specific content or categories.

AnQiCMS template directory structure specification

Understanding the template directory structure of AnQiCMS is the foundation for efficient management and development of templates. All related template files are stored in the/templateAs the root directory, each independent template needs to have its own exclusive directory under it.

Within a template directory, there is a directory namedconfig.jsonThe configuration file is indispensable. This file carries key information about the template, including the template name, package name, version, description, author, homepage, creation time, template type, and usage status. Althoughconfig.jsonThe fields are mostly optional, but they are crucial for the identification and management of the template. For example,namefields are used to specify the display name of the template,packageThe field represents the folder name of the template, andtemplate_typeIt indicates the responsive behavior of the template (0 for adaptive, 1 for code adaptation, 2 for PC + mobile). It is particularly noteworthy that,statusThe field (0 for disabled, 1 for in use) in an AnQiCMS installation can only have one template set as1which indicates the currently used template.

AnQiCMS offers two main template file organization modes to accommodate different development habits and project scales: folder organization mode and flattened file organization mode.

InFolder organization modeBelow, template files are logically grouped and stored in different subdirectories:

  • Public code files, such as the header and footer of a website, are usually named:bash.htmlfor other pages to inherit and reference.
  • Reusable code snippets, such as sidebars, breadcrumb navigation, etc., are stored inpartial/In the catalog.
  • The homepage file of a website is usuallyindex/index.html.
  • There will be a model homepage for different content models, for example{模型table}/index.html.
  • The document detail page can be{模型table}/detail.htmlor it can be specific to a document ID{模型table}/detail-{文档ID}.html.
  • The document list page is similar, it is{模型table}/list.htmlor it can be specific to a category{模型table}/list-{文档分类ID}.html.
  • The comment list page is usuallycomment/list.html, the online message page isguestbook/index.html.
  • The single page detail page ispage/detail.htmlor,page/detail-{单页ID}.html.
  • The search results page, tag page, and error page also have their corresponding default positions, such assearch/index.html/tag/index.html/tag/list.html/errors/404.html/errors/500.htmlas well aserrors/close.html.
  • As previously mentioned, if the mobile template is enabled, the file structure will bemobile/repeated in the directory as described above.

AndFlat file organization modeFiles should be placed directly in the template root directory, distinguished by the prefix or suffix of the filename to indicate their function and module. For example, the homepage isindex.html, and the model home page is{模型table}_index.html, the document detail page is{模型table}_detail.htmlThis pattern simplifies the directory hierarchy, but requires filenames to be more explicit and identifiable.

These organizational modes both allow for custom naming of some template files. This means that if you need to apply a unique template to a specific document, category, or single-page application, you can specify a custom template file name in the background settings (for examplepage/about.htmlAs long as the file exists in your template design package, the system can apply it to the corresponding page.This high degree of flexibility ensures that AnQiCMS can meet various personalized content display needs.

Frequently Asked Questions

1. Where can I find the detailed label usage document for AnQiCMS template creation?As an AnQiCMS operation personnel, I know that template tags are the core of content display.All template tags' detailed usage methods and parameter descriptions can be found in the "Template Creation" -> "Tags and Usage" and "Template Tag Invocation" sections of the AnQiCMS official documentation.This includes a comprehensive guide to 38 commonly used tags from system settings to document lists, category details, etc., which can help you efficiently build dynamic content pages.

2. What should I pay attention to when editing template files on Windows to avoid garbled characters?This is a common question. To ensure that your AnQiCMS website can display normally in different environments, the template files must use UTF-8 encoding consistently.When editing on Windows, be sure to save the file in UTF-8 format.Most modern editors (such as VS Code, Sublime Text, Notepad++) support selecting encoding format when saving. Please make sure you have selected the correct option to avoid page garbled text issues.

3. What types of template display modes does AnQiCMS support?AnQiCMS to meet the diverse needs of website requirements, provides three main template display modes: adaptive template type, code adaptation template type, and PC + mobile end template type.You can choose the most suitable model based on the audience and design strategy of the website.Among them, if you choose code adaptation or PC+mobile terminal mode, the system also supports designing and storing templates separately for mobile devices, and these mobile terminal templates should be placed in the main template directory.mobileIn the subdirectory.

Related articles

What are the mainstream search engines supported by AnqiCMS's link push function?

As an experienced website operator, I am well aware of the importance of timely inclusion after content publication for website traffic and SEO performance.AnQiCMS (AnQiCMS) provides many conveniences in content management, among which the link push function is a key factor in helping website content be quickly discovered by search engines.This article will introduce in detail the link push function supported by Anqi CMS, including the main search engine types and their configuration methods, aiming to help website operators better utilize this feature and improve the inclusion efficiency of the website.###

2025-11-06

How does AnqiCMS support Markdown editor and display mathematical formulas and flow charts?

AnqiCMS as an efficient and customizable content management system, has always been committed to providing convenient and powerful creation tools for content operators.In daily content operations, we know that high-quality, clear, and expressive content is the key to attracting and retaining users.For this, AnqiCMS has continuously evolved and now fully supports Markdown editors, can elegantly present complex mathematical formulas and intuitive flowcharts, greatly enriching the dimensions of content expression, and making our website stand out in the sea of information

2025-11-06

How does the homepage TDK setting affect the title, keywords, and description optimization of the website?

AnQi CMS is an enterprise-level content management system designed for small and medium-sized enterprises, self-media operators, and users with multi-site management needs, one of its core advantages lies in its deep support for search engine optimization (SEO).In website operation, the setting of the home page TDK (Title, Description, Keywords) is the cornerstone of SEO work, which directly determines the first impression and preliminary performance of the website on the search engine results page (SERP).At Anqi CMS backend

2025-11-06

How to create multi-level menus and customize navigation categories in the website navigation settings?

As a senior website operator, I am well aware of the importance of a clear and efficient website navigation for user experience and Search Engine Optimization (SEO).It is not only a map for users to explore the content of the website, but also a key for search engines to understand the structure of the website.AnQiCMS provides flexible and powerful website navigation settings, allowing us to easily create multi-level menus and customize navigation categories to meet the needs of different business scenarios.

2025-11-06

How to use similar Django variable and tag syntax in AnqiCMS templates?

As a senior security CMS website operation personnel, I know the core position of content in the digital age.An efficient content management system, especially its template function, is the foundation to ensure that website content can be presented flexibly and accurately to readers.The AnQi CMS excels in this aspect, drawing on the mature Django template engine syntax, allowing content creators and template developers to build pages in an intuitive and powerful way.### AnQi CMS template engine's Django-style grammar overview AnQi CMS template engine is designed cleverly

2025-11-06

How to fetch the document list according to category ID, recommendation attributes, etc. for the `archiveList` tag?

As a senior security CMS website operator, I am well aware that the flexibility and powerful functions of the content management system tags are the key to efficient content operation.`archiveList` tag is the core tool used in AnQiCMS to retrieve document lists. The subtle use of its parameters can help us accurately present the desired content, whether it's building the recommended articles for the homepage, displaying specific documents on category pages, or providing related recommendations on detail pages, all of which rely on our proficiency with this tag.###

2025-11-06

How to get the detailed information of a specified document, including custom fields, using the `archiveDetail` tag?

In the daily operation of AnQi CMS, obtaining and displaying detailed information of website content is one of the core tasks.The `archiveDetail` tag is a powerful tool specifically designed for this purpose in the Anq CMS template system, allowing us to flexibly extract detailed data from any specified document, including standard document properties and user-defined field content.

2025-11-06

How to get the category list and detailed information of a single category with the `categoryList` and `categoryDetail` tags?

As a senior AnQi CMS website operation personnel, I know that the flexibility of content organization and presentation is crucial for attracting and retaining users.The site classification structure is not only the skeleton of content, but also an important path for users to explore and discover information.Today, let's delve deeply into the two core template tags in Anqi CMS, `categoryList` and `categoryDetail`, and how they help us efficiently obtain and display category lists and individual category details.## Flexible Construction of Category Navigation: `categoryList`

2025-11-06