What is the directory structure of AnQiCMS templates, and how to organize template files for efficient display?

Calendar 👁️ 73

Build and manage website templates in AnQiCMS, first you need to understand its unique directory structure and file organization.This is not only about the visual presentation of the website, but also an important foundation affecting the performance, maintainability, and future scalability of the website.A clear and reasonable template organization strategy can make content operation and front-end development work twice as effective.

AnQiCMS template system overview

AnQiCMS uses a syntax similar to the Django template engine, with.htmlAs a template file suffix, this allows developers familiar with this template language to get started quickly.Its design philosophy is to strictly separate the front-end template files from static resources (such as CSS, JavaScript, images, etc.).All template files are stored in the root directory./templateIn the folder, while the static resources that the template depends on are placed uniformly in/public/static/the directory, this separation helps to optimize resource loading, facilitates browser caching, and is also beneficial for integrating CDN services.

The AnQiCMS template system also has high flexibility, supporting various website modes including adaptive, code adaptation, and independent PC and mobile site modes.It is particularly noteworthy that the system provides a special template storage mechanism to meet the special needs of mobile devices, ensuring a good user experience across multiple devices.

Core directory structure analysis:/template

/templateIs the root directory of AnQiCMS template, all template themes must be created in a separate folder under this directory. Each template theme folder should contain aconfig.jsonconfiguration file, used to describe the basic information and characteristics of the template.

config.jsonThe file is the 'ID card' of the template theme, containing the following key information:

  • name: The display name of the template, convenient for identification in the background.
  • package: The name of the template folder, usually consistent with the directory name, and only supports letters and numbers.
  • versionTemplate version number, for easy management and updates.
  • descriptionBrief introduction of the template.
  • author,homepage,createdAuthor information, homepage, and creation time.
  • template_typeDefine the compatibility type of the template, for example0For adaptive,1For code adaptation,2For PC+mobile. This determines how the system renders the page.
  • status: Template enable status,1indicates in use,0indicates not enabled.

Under each template theme directory, AnQiCMS provides two main template organization modes to meet different project requirements and development habits.

1. Folder organization mode

This pattern emphasizes modularity and structurization, through the creation of subfolders to classify and manage template files for different functional modules.

  • Public code files: bash.htmlCommonly used to store the public header, footer, and other parts that are inherited on each page of the website.
  • Code snippet directory: partial/The directory is used to store reusable code snippets, such as sidebars, breadcrumb navigation, ad spaces, etc., for easy use across different pagesincludeTag reuse.
  • Core page template:
    • index/index.htmlThe home page template of the website.
    • {模型table}/index.htmlThe list page of specific content models (such as articles, products).
    • {模型table}/detail.htmlThe default template of the specific content model detail page.
    • {模型table}/list.html: The default template for the list page of specific content model categories.
    • comment/list.html: The template for the comment list page.
    • guestbook/index.html: The template for the online message page.
    • page/detail.html: The default template for the single page detail page.
    • search/index.htmlSearch Results Page Template.
    • tag/index.htmlTag Homepage Template.
    • tag/list.htmlDocument List Page Template under Tag.
  • Error Page: errors/404.html,errors/500.html,errors/close.htmlUsed to display 404 errors, 500 errors, and prompts when the website is closed.
  • Mobile template directory: mobile/The directory has a structure similar to the PC template directory, used to store independent mobile template files, and plays a role when the website is set to "code adaptation" or "PC + mobile end" mode.

In this mode, AnQiCMS also supports more detailed custom template naming, for example:

  • Document default custom template:{模型table}/{文档id}.htmlAllow custom templates for specific document IDs.
  • Document list default custom template:{模型table}/list-{分类id}.htmlAllow customization of list templates for specific category IDs.
  • Default custom template for single page:page/{单页面id}.htmlIt allows customization of templates for specific single-page IDs. For example, if you need to create a customized template for the 'about-us' page with the ID 'about-us', you can createpage/about-us.html.

2. Flat file organization pattern

This pattern places all major template files directly in the root directory of the template theme, distinguishing page types through specific naming conventions. The file naming usually adopts{类型}_页面名.htmlin the form of.

  • index.html: Home page.
  • {模型table}_index.html: Model homepage.
  • {模型table}_detail.html: Model details page.
  • {模型table}_list.html: Model list page.
  • guestbook.html: Message page.
  • page.html,page-{单页ID}.html: Single page and its customized template.
  • errors_404.html,errors_500.html,errors_close.htmlError page.
  • Same as well.mobile/The catalog is used for mobile templates, its internal structure is consistent with the flattened PC mode.

Flattened mode is suitable for projects with a relatively simple structure or when developers prefer to view all template files directly.

Key strategies for efficient display: template organization and utilization.

To achieve efficient display and management of templates, it is not only about placing files according to regulations, but also taking full advantage of the features provided by AnQiCMS:

  1. Modularization and reusability come first:

    • Abstract the common elements of the website (such as navigation, footer, sidebar) asbash.htmlorpartial/the fragments under the catalog. Through{% include "partial/sidebar.html" %}Such tags can be reused on multiple pages, greatly reducing the amount of repetitive development and improving maintenance efficiency.
    • Utilize{% extends 'base.html' %}and{% block content %}Implement template inheritance to build the overall layout "skeleton" of the website, and then fill in or rewrite specific areas for different pages.This ensures consistency in the website style while also maintaining the independence of local content.
  2. Customization and flexible application:

    • AnQiCMS allows for background customization ofdocument, category and single pageSpecify an independent template file. This means you can design a unique display page according to the specific content needs.For example, a special promotional page or a product landing page can be customized to have a layout and functionality by filling in a custom template name in the corresponding content editing interface in the background.
    • Make full use of the custom template naming rules mentioned earlier (such aspage/{单页面id}.html), you can directly set up customized templates for key pages at the file system level, without any additional backend configuration.
  3. Responsive and multi-end adaptation:

    • When choosing the "Code Adaptation" or "PC + Mobile End" template type, be sure to create it under the template theme directorymobile/Folder, and place the mobile-specific templates in it according to the same organization pattern as on the PC.AnQiCMS will automatically select the corresponding template based on the access device, achieving elegant multi-end adaptation.
  4. Static resource optimization management:

    • The separation of static resources and template files allows front-end developers to focus on optimizing CSS, JS, and images, such as compression, merging, and sprite sheet processing.By deploying static resources to a CDN, it can significantly improve the loading speed and user experience of the website.When referencing static resources in the template, you can use{% system with name="TemplateUrl" %}Dynamically obtain the static resource path of the current template theme and ensure the path is correct.

AnQiCMS template engine and tag usage

The AnQiCMS template engine provides rich tags and filters for handling data and control logic. For example:

  • Variable output:Use{{ 变量名 }}to display data such as{{archive.Title}}display the article title.
  • Conditional judgment: {% if 条件 %}...{% endif %}Used to display different content based on conditions.
  • Loop traversal: {% for item in 列表 %}...{% endfor %}Used to iterate over list data, such as article lists, navigation menus, etc.
  • System-level tags: {% system %}/{% contact %}Etc., used to obtain global configurations such as website name, contact information, etc.
  • Content-related tags: {% archiveList %}/{% categoryDetail %}Used to get article list, category details, and other content data.
  • Filter: |safeUsed to output HTML without escaping.|stampToDateUsed to format timestamps.|truncatecharsUsed for truncating strings, etc., which greatly enhances the data processing ability of templates.

A clear template directory structure and a reasonable organization method are the foundation for the efficient operation, easy maintenance, and flexible expansion of the AnQiCMS website.By fully understanding and utilizing the template mechanism provided by AnQiCMS, content operators and front-end developers can work more efficiently together to build high-quality websites.


Frequently Asked Questions (FAQ)

Q1: How to create a new template theme in AnQiCMS?A1: To create a brand new template theme, you need to create a new folder under AnQiCMS's/templatedirectory, for example namedmythemeThen, create a new folder hereconfig.jsonFile, and fill in the basic information of the template (such as name, version, author, etc.). Then, according to your design requirements, organize in the folder mode or flat mode, inmythemeCreate the corresponding template file inside the folder (such asindex/index.html/partial/header.htmlAfter completing it, you can select and enable your new template theme in the 'Template Design' or 'System Settings' of the AnQiCMS backend.

Q2: How should I organize the template if my website needs different designs for PC and mobile?A2: When you need to adopt a completely different design for the PC and mobile ends, you should in the template theme'sconfig.jsonfile willtemplate_typeis set to1Or (code adaptation)2(PC+phone). Based on this, you need to create a subdirectory namedmobile/in your template theme directory. All template files for mobile display should be placed in thismobile/Under the directory, and maintain the same structure and naming conventions as the PC template directory (or flattened files).AnQiCMS intelligently loads the corresponding template based on the type of user's device, ensuring that users of different devices can experience the **interface.

Q3: Can I set a completely independent template file for a specific article (such as "About Us"), rather than using the default detail page template?A3: Of course, you can. AnQiCMS provides highly customizable features to meet such needs.You can create a specific template file for this article in the template theme directory, for example, if "About Us" is a single-page content, you can createpage/about-us.html. Then, when editing the single page "About Us" in the AnQiCMS backend, find the "Single Page Template" field, and enter the name of the template file you created (such asabout-us.html). After saving, when accessing the single page, the system will load the specified independent template file instead of the default one.page/detail.html. For article or product detail pages, similar settings can also be made through the 'document template' field on the corresponding content editing page.

Related articles

What are the basic conventions to follow when making AnQiCMS templates to ensure correct content display?

Build a website template in AnQiCMS, as if designing a beautiful appearance and a practical functional framework for the website.Ensure that the carefully designed content is accurately displayed to visitors, it is crucial to follow some basic template design conventions.These conventions can not only help you efficiently complete template development, but also ensure the stability of the website and the convenience of future maintenance. ### One, the organization and coding specifications of template files Firstly, AnQiCMS has clear requirements for the **location and naming** of template files. All template files should be written with `

2025-11-08

How does AnQiCMS improve website content loading speed and user display experience through static caching?

In today's fast-paced digital world, website loading speed directly affects the first impression and the time spent by users on the website.A fast-loading website not only enhances user experience but is also one of the key factors in search engine optimization (SEO).AnQiCMS deeply understands this point, and has built-in powerful static caching mechanisms, aiming to fundamentally improve your website's performance and user experience. ### Understanding Static Caching: The Secret Weapon of Website Acceleration Imagine that your website is a bustling café.Each time a customer orders coffee (visits a page)

2025-11-08

How does the scheduled release feature ensure that my content goes live and is visible to the public at a specific time?

As content creators or website operators, we know how important the rhythm of content publishing is.Maintain a stable update frequency, push the latest information during the peak period of user activity, and even accurately release for different time zone audiences. All of these are directly related to the exposure and interaction effect of the content.However, manual operation is not only time-consuming and labor-intensive, but also prone to errors, especially when frequent releases or cross-time zone operations are required.Fortunately, the timed publishing function of AnQiCMS (AnQiCMS) perfectly solves these problems, making content operation easy and efficient.Scheduling post

2025-11-08

How to set up user groups and VIP systems to achieve differentiated content display and paid access?

In today's digital world, content operation is no longer just about publishing and displaying.In order to better serve different user groups, achieve content monetization, and build a vibrant user community, fine-grained user management and differentiated content services are particularly important.AnQi CMS understands this need and provides powerful user group management and VIP system functions, allowing you to easily implement personalized content distribution and paid access, thereby fully tapping into the commercial value of the content.

2025-11-08

How to set up independent templates for specific documents, categories, or single pages to control their display styles?

In AnQiCMS, setting up independent templates for specific documents, categories, or single pages is a key feature for achieving personalized content display and enhancing user experience on the website.This not only makes the website design more flexible, but also allows for precise style control for different types of content, thus better satisfying the brand positioning and content operation strategy.### Understanding AnQiCMS Template Mechanism AnQiCMS provides two main ways to apply custom templates: one is that the system automatically identifies and loads templates based on file naming rules

2025-11-08

How to use the `archiveList` tag in AnQiCMS templates to flexibly display document lists?

In AnQi CMS, when we need to dynamically display articles, products, or other document lists on the website, the `archiveList` tag is an indispensable core tool.It provides high flexibility and powerful features, whether you want to display the latest content, hot articles, products in specific categories, or even generate lists based on keyword search or custom filtering conditions, `archiveList` can easily handle it.### `archiveList` core functionality and basic usage `archiveList`

2025-11-08

How is the `archiveDetail` tag used to retrieve and display detailed content information for a single document?

In AnQi CMS, the `archiveDetail` tag is a very core and practical tool for template creation, mainly used to retrieve and display detailed content information of a single document.Whether it is a blog post, product details, news report, or any other page content that needs to be independently displayed, `archiveDetail` can help you flexibly extract and present it on the website's front-end page.### `archiveDetail` Tag Core Function Overview The purpose of this tag is to provide rich data support for a single document

2025-11-08

How to use `categoryList` and `categoryDetail` tags to build and display category navigation and details?

In website content management, category navigation and detail pages are the core paths for users to browse the website and obtain information, as well as an important basis for search engines to understand the website structure.A clear and intuitive classification system not only greatly enhances the user experience, but also effectively helps the website's SEO performance.For users of Anqi CMS, flexibly using the `categoryList` and `categoryDetail` template tags provided by the system can easily build powerful, beautiful, and practical classification navigation and detail display.--- ### One

2025-11-08