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

Calendar 👁️ 72

Build website templates in AnQiCMS, just like designing a beautiful appearance and practical functional framework for a website.Make sure that the carefully designed content is accurately displayed to visitors, and it is crucial to follow some basic template creation conventions.These conventions can not only help you complete template development efficiently, but also ensure the stable operation of the website and the convenience of future maintenance.

1. The organization and coding standards of template files

Firstly, AnQiCMS has specific requirements for thestorage location and namingof template files. All template files.htmlshould have as their file extension, and should be stored in a unified manner./templateThis root directory. If you need to include static resources such as styles (CSS), scripts (JavaScript), or images in the template, please place them in/public/static/In the directory, so that the system can load it correctly.

A point that is easily overlooked but is extremely important isFile encoding. All template files must be unified using UTF8 encoding.Especially for Windows users, be sure to confirm the encoding format when editing and saving template files, otherwise it may cause garbled characters on the page, affecting the user experience.

AnQiCMS supports a variety ofTemplate TypeTo meet the needs of different website display requirements: including responsive (Responsive), code adaptation (Code Adaptation), and PC + mobile independent site (PC + Mobile Independent Site) mode. If you choose code adaptation or PC + mobile independent mode, then you need to create independent template files for the mobile end, which will be stored in the template directory.mobileIn the subdirectory.

Second, template engine syntax and variable naming rules

The AnQiCMS template system is based on a syntax similar to the Django template engine, making dynamic content display very intuitive.

Output of the variableUsing double curly braces{{变量}}The form, for example, to display the document title, you would use{{archive.Title}}. In variable naming, it is recommended to followcamel case naming conventionThis means capitalizing the first letter of each word, which helps maintain consistent coding style, for examplearchive.Id/archive.Titleetc.

Logical control tagsFor conditional judgments and loops, use single curly braces and percent signs, for example{% if 条件 %}/{% for item in list %}. It should be noted that these logical tags usually need oneend tagto define their scope, for example{% endif %}and{% endfor %}. Properly closing tags is crucial to avoid parsing errors.

Three, Template Directory Structure and Automatic Matching Mechanism

A complete AnQiCMS template, in addition to the core HTML files, also needs oneconfig.jsonConfiguration file, used to describe the basic information of the template, such as the template name(name), version(version), authorauthor), and most importantly,Template Type(template_type), andenable status(status). Among them,statusA field is crucial, as it determines which set of templates is currently being used by the system, and only one template can be used in all templates.statusThe value is 1.

AnQiCMS provides twotemplate file organization mode: Folder organization mode and flat mode. These two modes have their own characteristics, but they both aim to provide a clear structure to manage core pages such as home page, model home page, document detail page, list page, single page, search page, etc.No matter which mode you choose, the system has built-in someDefault Custom Template Name RuleAs long as you create template files according to these rules, the system can automatically recognize and apply them without needing to set them separately in the background.

For example, for the article detail page, the system will try to find{模型table}/{文档id}.htmlsuch a template file; for the list page, it is{模型table}/list-{分类id}.htmlThis flexible naming method also supports the creation of unique templates for specific categories or single-page applications, such as creating for the "About Us" pagepage/about.htmlwhich greatly enhances the customization capabilities of the template.

Four, the correct use of common tags and filters

AnQiCMS has a wealth of built-inTemplate tags and filtersThey are a powerful tool for building dynamic content. For example,{% system %}The label is used to get the website name, LOGO, and other global system settings;{% contact %}Used to display contact information;{% tdk %}

Related articles

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 can AnQiCMS protect the display rights of original content through anti-crawling and watermark management functions?

On a day when digital content is flourishing, the value of original content becomes increasingly prominent.However, the problems of content theft and malicious collection that follow also make creators and operators headache.Protect the display rights of original content, not only related to the author's labor成果, but also directly affects the brand image of the website and the performance of search engine optimization (SEO).It is crucial for small and medium-sized enterprises and self-media operators to choose a content management system that can effectively resist these risks.

2025-11-08

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

Build and manage website templates in AnQiCMS, the first step is to understand its unique directory structure and file organization.This not only concerns the visual presentation of the website, but also affects the performance, maintainability, and future scalability of the website.A clear and reasonable template organization strategy can greatly improve the work of content operation and front-end development.### Overview of AnQiCMS Template System AnQiCMS uses a syntax similar to the Django template engine, with `.html` as the template file suffix, which allows developers familiar with this template language to get started quickly

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