What template file extensions and storage locations does AnQiCMS support?

Calendar 👁️ 74

AnQiCMS as a flexible and efficient content management system provides powerful template customization capabilities.It is crucial to make full use of this advantage of AnQiCMS and understand the suffix and storage location of its template files.This can not only help you design websites more efficiently, but also locate and solve problems faster when encountered.

Firstly, AnQiCMS template files are unified using.htmlas a suffix. This means that all template files you create or edit should be saved in HTML format. These.htmlare stored in the root directory of the website./templatein the folder./templateThis is the 'home base' for AnQiCMS to recognize and load templates.

To better manage templates of different themes or styles, AnQiCMS allows you to create independent template sets. Each template set is located/templateA directory has its own exclusive subfolder, such as/template/default(System default template) or one customized by you/template/my_custom_theme. Each suite folder internally needs to contain aconfig.jsonA file used to describe the basic information of this template set, such as the template name, version, author, and the types of websites it supports (adaptive, code adaptation, or PC + mobile independent site).

It is noteworthy that the template file itself only contains structure and logic.And the stylesheets (CSS), JavaScript scripts, images, and other static resources used in the template will not be placed directly in the template kit folder.They are managed uniformly in the root directory of the website/public/static/In the catalog. This separation helps keep the template file tidy and optimize the loading of static resources.

AnQiCMS provides two modes for organizing template files to accommodate the habits of different developers:

One isFolder organization modeIn this mode, template files are further subdivided into subfolders by function or content type. For example, the home page template may be locatedindex/index.html, and the article detail page template may be locatedarchive/detail.htmlThis kind of structure is clear, convenient for managing large websites.

Another one isFlat file organization mode. As the name implies, in this mode, most commonly used template files are placed directly in the root directory of the template suite, distinguished by filenames, for example, the home page template isindex.html, the article detail page isarchive_detail.htmlThis approach may be more concise for small websites or personal blogs.

Regardless of the mode used, AnQiCMS supports a set of standard file naming conventions to facilitate automatic recognition and application by the system. For example,bash.htmlCommonly used to define the common header and footer,partial/The catalog stores reusable code snippets such as sidebars and breadcrumbs. AnQiCMS also supports more precise template specification for specific content:

  • Model and category pageYou can define default templates for document detail pages and list pages, for example{模型table}/detail.htmlor{模型table}_detail.htmlAnQiCMS even supports specifying templates for documents or categories with a specific ID, formatted as{模型table}/{文档id}.html(for documents) or{模型table}/list-{分类id}.html(For lists).
  • single page: For single-page items like "About Us" and "Contact Us", there can bepage/detail.htmlAs a default template, it can also create specific single pages (such as pages with ID 10).page/{单页面id}.htmltemplate for exclusive use.
  • error page: commonerrors/404.htmlanderrors/500.htmlused to display 404 and 500 error pages,errors/close.htmland is used for the prompt page when the website is closed.
  • Mobile templateIf your website needs to support an independent mobile site or code adaptation, just create one in the template package directorymobileSubfolder, and repeat the directory structure and file naming of the PC template according to one of the two modes mentioned above.AnQiCMS will automatically load the corresponding mobile template based on the visiting device.

In addition to these agreements, you can also specify a template file for a specific category, document, or single page in the background content managementManually specify the template fileFor example, if you create a specialdownload.htmltemplate, just set the template field to the document when editing it in the backgrounddownload.html,AnQiCMS will load the file for rendering.

This flexible file extension and storage strategy, combined with clear naming conventions, makes AnQiCMS's template system both powerful and easy to manage.It ensures website performance, while giving developers great freedom to customize the interface, meeting diverse display needs.


Frequently Asked Questions (FAQ)

  • Q1: Besides the template file,.htmlDo you support suffixes such as.tplor.twigand other suffixes?AnQiCMS's template system is designed to be unified using.htmlAs a template file suffix. Although its syntax is similar to the Django template engine, it is recommended to follow this convention to maintain system consistency and ease of use, all template files should be extended with.html.

  • Q2: If I want to load different templates for the same page (such as article detail page) based on different conditions (such as user role or article type), does AnQiCMS support this?Yes, AnQiCMS supports this customization requirement. In addition to the system default naming conventions, you can also manually specify the template file name for specific content (such as categories, documents, or single pages) in the background.For example, you can create content for VIP usersarchive/vip_detail.htmlTemplate, and set the 'Document Template' field of related VIP articles in the backgroundvip_detail.html.

  • Q3: Where are the static resources such as CSS, JavaScript, and images placed in the template?/public/static/After placing them in the directory, how can you correctly reference them in the template?When referencing these static resources in the template, you can use relative paths or combine system tags to build the correct URL. In most cases, you can use them directly.{% system with name="TemplateUrl" %}This tag is used to obtain the root path of static resources under the current template suite, and then add your resource path after it, for example<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">Or use a similar/static/img/logo.pngto refer to such a relative root path.

Related articles

How to implement personalized display of front-end content in AnQiCMS?

In today's era of content overload on the internet, how to make a website stand out and provide a unique and valuable experience to visitors has become crucial.The personalized display of content is an important means to enhance user stickiness, conversion rate, and brand image.AnQiCMS as an efficient and customizable content management system provides many features to help us easily achieve this goal.The flexible construction of content models: the foundation of personalized display The first step in personalized display is to make our content inherently personalized.The flexible content model feature of AnQiCMS

2025-11-08

How to display the title and content of articles in AnQiCMS templates?

Manage website content in AnQiCMS, the ultimate goal is to be able to present this content to visitors in an elegant and efficient manner.For the most common content type of articles, how to accurately display the title and body in front-end templates is a basic skill that every website operator needs to master.AnQiCMS powerful template function, providing us with a flexible and intuitive implementation method.### Core: Get to know the `archiveDetail` tag AnQiCMS's template system is designed to be very user-friendly

2025-11-08

How to get the string in AnQiCMS template?

In AnQiCMS template development, text and strings are the foundation for building website content.Flexible and efficient string retrieval and manipulation are skills that template developers must master, whether it is to display article titles, website names, or process user input.AnQiCMS's powerful template engine is based on Go language, providing rich tags and filters, making string acquisition and processing intuitive and practical.### Core Mechanism: Understanding the String Retrieval Method of AnQiCMS Template The most direct way to retrieve strings in AnQiCMS templates is through variable references

2025-11-08

What is the type of the string array after splitting the `fields` filter in AnQiCMS template?

In AnQiCMS template development, we often need to process text content, such as splitting a string of keywords, tags, or descriptions into independent entries for list display or further operations.At this time, the `fields` filter has become a very practical tool.It can efficiently complete the splitting of strings, but many users may be curious about the data types of the split strings after the `fields` filter is applied.Understand the working mechanism of the `fields` filter

2025-11-08

How to use AnQiCMS built-in tags to control content display logic?

In AnQiCMS, the built-in tag system is the core tool you use to control the logic of displaying website content.It provides a powerful and flexible syntax that allows you to control the acquisition, filtering, sorting, formatting, and final layout of content in template files without writing complex backend code.This system is similar to the Django template engine syntax, easy to use, and can help you convert technical details into intuitive display effects.

2025-11-08

How does AnQiCMS adapt the display of website content for PC and mobile endpoints?

AnQiCMS: Providing seamless PC and mobile end adaptive display solutions for your website In today's digital age, it is common for users to access websites through various devices, from large computer screens to small smartphones, and the display effect of the website directly affects user experience and the efficiency of information transmission.A website that cannot be displayed friendliness on mobile devices will undoubtedly lose a large number of potential users and business opportunities.AnQiCMS fully understands this requirement and has provided flexible and diverse solutions to ensure that your website content is perfectly presented on both PC and mobile ends

2025-11-08

How to display the list of articles by category in AnQiCMS?

It is crucial to organize and display information efficiently in website content management.For users, being able to clearly browse article lists by different categories greatly enhances the access experience and also helps search engines better understand the website structure, thereby optimizing SEO effects.AnQiCMS (AnQiCMS) provides us with flexible and powerful tools, making this requirement easily accessible.

2025-11-08

How to set the number of articles or products displayed per page in AnQiCMS?

In website operation, especially when managing pages that require a large amount of content display, such as article lists and product display pages, how to efficiently control the number of items displayed per page directly affects user experience and page loading speed.AnQiCMS provides a flexible and powerful mechanism to meet this requirement, it allows you to customize the display of each page according to different page and content types through fine-grained control at the template tag level.The Anqi CMS can provide this flexibility because it closely integrates the display logic of the list content with the template design

2025-11-08