What basic conventions should the template files of Anqi CMS follow to correctly display the content structure?

Calendar 👁️ 70

In AnQi CMS, template files are the basis for displaying website content.It is not just a simple HTML file, but a set of blueprints that follow specific conventions and rules. Only by accurately adhering to these conventions can the system correctly parse, render, and display the structure of your website content.Understanding these basic conventions can help you customize and manage your website more efficiently, ensuring that content is presented to visitors in the way you expect.

The storage location and basic format of template files

Firstly, AnQi CMS has specific requirements for the storage location of template files. All template files should be placed uniformly under the root directory of the website./templateIn the folder. Each independent template needs to be in this/templatedirectory to create a dedicated folder, and include a single oneconfig.jsonConfiguration file, this file is like the 'ID card' of the template, informing the system of the template's name, version, author, and most importantly—the template type and enabled status.

And the naming of the template files is very intuitive, they use uniformly.htmlAs a file extension. As for the CSS styles, JavaScript scripts, and static resources such as images used in the template, they need to be stored separately./public/static/In the directory, this can keep the template directory tidy and is also beneficial for website performance optimization.

In addition, a seemingly minor but crucial detail is the file encoding. All template files must be unified in their adoption.UTF-8 EncodingIf other encoding formats are used, the page content may appear garbled and cannot be displayed normally.For users who edit templates on the Windows system, be sure to save the file in UTF-8 format when saving.

AnQi CMS template engine and syntax

The template core of AnQi CMS adopts a syntax similar to the Django template engine, which allows developers familiar with Blade templates or similar syntaxes to get started quickly.

The reference to data variables is very direct, you just need to enclose the variable name in double curly braces, for example{{变量名}}. The system will automatically fill in the corresponding data into these positions according to the context of the current page.

For more complex logic control, such as conditional judgment,if)、looping over(forBrackets such as need to be defined using single curly braces and the percentage sign, for example{% if 条件 %}It is noteworthy that these logical tags usually need a corresponding end tag, such as{% endif %}or{% endfor %}Pairwise structures are formed to ensure the integrity of logical blocks.On variable naming, Anqi CMS recommends using CamelCase naming conventions, where the first letter of each word is capitalized, which helps improve the readability and consistency of the code.

The type and refinement of the template

AnQi CMS provides various template types to meet different website construction needs, including adaptive templates, code adaptation templates, and PC + mobile independent site mode. This isconfig.jsonin the filetemplate_typeSet the field. If you choose code adaptation or PC+mobile independent mode and want to provide an independent template for mobile devices, then you need to create a folder namedmobileThe subdirectory, and in it, store the mobile template files in a structure similar to the PC template.

On file organization, AnQi CMS provides two main modes: folder organization mode and flat file organization mode.No matter which mode, the system has preset some default template file names. As long as these files exist in your template directory, the system can automatically apply them without any separate settings in the background.

For example:

  • Home pageIt is usuallyindex/index.htmlorindex.html.
  • Content model home page(such as the article list page or product list page) can be{模型table}/index.htmlor{模型table}_index.html.
  • Document detail page(such as a single article or product detail) can be{模型table}/detail.htmlor{模型table}_detail.html.
  • Category list pageis{模型table}/list.htmlor{模型table}_list.html.
  • a single page detail pagelike the 'About Us' page, can bepage/detail.htmlorpage.html.

It is more powerful that, Anqi CMS supports the use of custom templates for specific content items.This means you can specify a completely independent template file for a specific document ID, category ID, or single page ID.For example, if you have an article with ID 10 that needs special display, you can create aarticle/10.htmltemplate; or create a single 'About Us' pagepage/about.htmlThe template, and configure the page to call this custom template in the background. This flexibility allows the presentation of website content to be highly personalized.

Intelligent mapping of content and template

After understanding these conventions, you will find that Anqi CMS does a very intelligent job in combining backend data with frontend templates.When a visitor requests a page, AnQi CMS will automatically search and render the most suitable template file based on the URL, backend configuration, and current template directory structure, and pass related data (such as article titles, content, category information, etc.) to the template through predefined tags and variables.

For example, on the document detail page, you can use{{archive.Title}}to get the article title, use{% archiveDetail with name="Content" %}to display the article content; on the category list page, you can use{% categoryList categories with moduleId="1" %}to iterate through the article categories, and use{% for item in categories %}Output the name and link of each category. These built-in tags and variables greatly simplify the interaction process between content and templates, allowing you to focus on content creation and page design.

Summary

The AnQiCMS template file conventions aim to provide a standardized and flexible framework.By placing files in the correct location, using unified encoding, adhering to similar Django template syntax, and making good use of its various template types and custom naming mechanisms, you will be able to fully utilize the powerful functions of the AnQi CMS to build a website with clear structure, rich content, and strong visual appeal.Familiarize yourself with and apply these basic conventions, which are a key step in your efficient operation of the Anqi CMS website.


Frequently Asked Questions (FAQ)

1. Why does the content displayed by my website template show garbled characters?If your website template displays garbled text, the most common reason is that the encoding format of the template file is incorrect.The AnQi CMS requires all template files to be encoded in UTF-8.Please check your.htmlFiles, make sure they are saved in UTF-8 format. If you are using a Windows system, pay special attention to selecting the UTF-8 encoding option when saving files.

2. Why is the custom template I set for a category or document not working on the frontend?There may be several reasons for this situation:

  • Template file does not exist or the path is incorrect: Make sure you have created the corresponding custom template file in the template directory, and the file name and path must match the settings in the background. For example, if the background is set todownload.htmlThen the file should be in the root directory of the current template, not in a subfolder, or if set toarticle/download.htmlthen the file should betemplate/您的模板名称/article/download.html.
  • Template type does not match:Checkconfig.jsonoftemplate_typeDoes it match your actual website requirements (such as PC + mobile independent mode)? If it is a mobile template, is the file placed inmobiledirectory.
  • Cache problem:Try to clear the system cache of Anqi CMS, sometimes the cache can cause the new template to not take effect immediately.

3. How does AnqiCMS identify which template file should be used for the homepage, article detail page, or category list page of my website?SafeCMS identifies through a set of intelligent matching rules.Firstly, it will judge the current page is the homepage, article detail, category list, or other types based on your website URL structure.Then, it will look for the corresponding template file in the currently enabled template directory, following the predefined default naming convention, for exampleindex.htmlrepresents the home page,{模型table}/detail.htmlRepresents document details,{模型table}/list.htmlRepresent a category list. If you set specific content items in the background (such as a category or document ID

Related articles

How to correctly display and load images on the front-end page after the website enables Webp image format?

In website operation, the speed of image loading is crucial for user experience and Search Engine Optimization (SEO).WebP is a modern image format that, with its excellent compression performance, significantly reduces file size while maintaining image quality, thus greatly enhancing website loading speed.AnQiCMS (AnQiCMS) fully understands this and has built-in support for WebP image format in its system, making it easy for users to turn it on and benefit from it.However, after enabling the WebP feature, many users may be confused: how can the front-end page correctly display and load these WebP images

2025-11-09

How does Anqi CMS handle and display external links in content, such as adding the `rel="nofollow"` attribute?

In website operation, the management of external links is an indispensable part of content strategy and search engine optimization (SEO).Especially properties like `rel="nofollow"`, which tell search engines not to pass link weight to the linked page, are crucial for managing the link health of a website and avoiding potential SEO risks.AnQiCMS (AnQiCMS) provides multiple ways to handle and display external links in content, including automatically adding the `rel="nofollow"` attribute

2025-11-09

How to call the backend custom Json-LD structured data in AnQi CMS template and display it?

Today with the rich content on websites, how to make search engines accurately understand web content and display it in a more user-friendly manner has become a key link in website operation.Structured data (usually in Json-LD format) is an important tool to achieve this goal.By embedding Json-LD code in the page, we can provide standardized information for search engines about various content such as articles, products, and reviews, thereby having the opportunity to obtain richer search result displays, which is what we commonly refer to as 'rich snippets' or 'rich results'

2025-11-09

How to implement complex parameter filtering conditions for the dynamic display of the `archiveFilters` tag on the front end?

In website content operation, providing users with flexible and efficient filtering functions is an important factor in improving user experience and helping users quickly locate the information they need.AnQiCMS (AnQiCMS) knows this, making it easy to dynamically display complex parameter filtering conditions on the front end through its powerful template tag system, especially the `archiveFilters` tag.### Core Function and Implementation Principle The core function of the `archiveFilters` tag is to use the custom fields of the content model

2025-11-09

How to debug template display issues in AnQi CMS, such as using the `dump` filter to print variables?

Aqy CMS template debugging: Use the `dump` filter to easily locate display problems When building a website with Aqy CMS, we sometimes encounter situations where the template content is not displayed as expected.For example, you expect to display the article title at a certain location, but it turns out to be blank;Or the list data is incomplete, the content of a custom field is always unable to be presented correctly.These issues often confuse people, because it is clear that data has been set in the background, but for some reason the front-end does not display.If one can 'penetrate' the real content of the variables in the template, it will undoubtedly greatly improve the efficiency of solving such problems

2025-11-09

How to display the navigation list configured in AnQi CMS and support multi-level dropdown menus?

The website navigation acts as a 'compass' for users visiting the website, and its clarity and ease of use directly affect user experience and the efficiency of information acquisition.For a corporate website, a well-structured navigation system that supports multi-level dropdowns is essential.AnQiCMS (AnQiCMS) understands this and provides an intuitive and powerful backend configuration function, allowing you to easily build a navigation menu with a sense of hierarchy.Next, we will explore how to configure the navigation list in the Anqi CMS backend and make it perfectly present multi-level dropdown effects on the front end.--- ### Step 1

2025-11-09

How to use the `lorem` tag to generate placeholder text in the early stages of development, and quickly preview the display effect of the template?

At the early stage of website template development, designers and developers often face a common challenge: how to effectively preview and adjust the layout, style, and responsive performance of the template without real content?If each modification requires manual input of a large amount of text to test the effect, it will undoubtedly greatly reduce development efficiency.AnQi CMS knows this pain point and provides a very convenient and efficient built-in tag called `lorem`, which can help us quickly generate placeholder text during the development stage, so that we can focus on the visual presentation of the template itself.### `lorem`

2025-11-09

How to display user group (VIP system) information in AnQiCMS to support member level display?

In today's internet world, the member system of websites and user grouping functions have become increasingly common. It not only helps operators provide differentiated services, but also is an important means to realize content monetization and enhance user stickiness.AnQi CMS knows this, therefore it has built a powerful user group management and VIP system, allowing the website to flexibly provide customized content and permissions for different user groups.How can we clearly display user group information (that is, VIP level) on the front-end page of a website built with Anqi CMS?This is actually more direct than imagined

2025-11-09