What template engine syntax does AnQiCMS template support, and what are the formats of its variables and tags?

Calendar 👁️ 55

As an experienced AnQiCMS (AnQiCMS) website operator, I know the importance of an efficient and easy-to-use template system for website content management and user experience.AnQi CMS does an excellent job in this aspect, providing a strong and flexible template system that makes content presentation intuitive and highly customizable.Now, let's delve deeper into the syntax, variables, and tag formats supported by the AnQiCMS template.

The core of AnQiCMS template system lies in its support forDjango template engine syntaxand its expression is similar to that of popularBlade syntaxThere are many similarities.This means that whether you are familiar with Django templates in the Python ecosystem or Laravel Blade in the PHP world, you can quickly get started with the template creation of Anqi CMS.This design concept greatly reduces the cost of learning, allowing website operators to invest more energy in high-quality content creation and user experience optimization.

On the file organization level, Anqi CMS has clear conventions for template files. All template files are uniformly named using.htmlas file extensions and stored centrally in/templateUnder the directory.This centralized management method makes the template resources clear at a glance, convenient for search and maintenance./public/static/In the directory, it ensures the separation of static resources from template logic.When editing template files, be sure to pay attention to the unified encoding format of UTF-8 to avoid possible page garbling problems, which is the basis for ensuring correct content display.

In terms of data presentation, the Anqi CMS template usesVariablevery intuitive. They usedouble curly braces{{ 变量名 }}to wrap, for example{{system.SiteName}}and can directly output the website name,{{archive.Title}}The article title will be displayed. This concise syntax makes data binding clear at a glance. It is worth noting that variable naming followscamel case naming conventionThis means that each word's first letter is capitalized, which needs to be followed when referencing built-in or custom data, for examplearchive.Id/archive.Title.

In addition to variables, the Anqi CMS template engine also provides richTagto control the page logic and content structure. These tags are usedsingle curly braces and percent signs{% 标签名 %}to define, and most control flow tags requireto appear in pairsThis means there is a start tag and a corresponding end tag, such as the one used for conditional judgments.{% if 条件 %}{% endif %}and loop iteration.{% for item in 列表 %}{% endfor %}This structured syntax ensures the clarity and integrity of the template logic.

The Anqi CMS is built-in with up to thirty-eight commonly used tags, covering all aspects of website content management. These tags greatly simplify the template development work:

  • System and configuration tagssuch assystemUsed to get the global settings of the website (such as website name, Logo, etc.),contactUsed to get contact information,tdkUsed to manage the page Title, Description, and Keywords.
  • Content management tagssuch asarchiveListUsed to retrieve articles, product lists,archiveDetailUsed to display the details of a single article;categoryListandcategoryDetailUsed to handle category lists and details;pageListandpageDetailIt is specifically used for displaying on a single page.
  • Auxiliary and control flow tagsFor examplenavListUsed to build multi-level navigation menus,breadcrumbCan automatically generate breadcrumb navigation,paginationUsed to handle pagination logic,ifandforTags provide powerful conditional judgment and loop iteration functions.
  • Time processing tagsuch asstampToDateCan convert a 10-digit timestamp to a date-time format supported by Go language (such as{{stampToDate(item.CreatedTime, "2006-01-02 15:04")}}), which greatly facilitates the display of time data.

In addition, the Anqi CMS template engine supports powerfulFiltermechanisms. By using a pipe symbol after variables|to connect filter names, variables can be processed more finely, and the format is{{变量 | 过滤器名:参数}}For example,{{ item.Description|truncatechars:100 }}Truncates the article description to one hundred characters,{{ item.Content|safe }}It can prevent variables containing HTML content from being automatically escaped. For content fields enabled with Markdown editors on the backend (such asarchiveDetailandcategoryDetailofContentField), Anqi CMS will automatically convert it to HTML to ensure the correct rendering of content.

In summary, the Anqi CMS template system, with its familiar Django-like syntax, combined with clear variable and tag formats, provides a powerful and flexible content presentation platform for website operators.Mastering the usage of these basic grammatical structures and built-in tags will enable you to efficiently customize the appearance of your website, optimize content display strategies, and thereby better attract and retain your target users.


Frequently Asked Questions (FAQ)

1. Q: Why does the page show garbled text after editing the template?

A: Garbled text in template files is usually due to the file

Related articles

How to use a custom template for specific documents, categories, or single pages in AnQiCMS?

As an experienced AnQiCMS (AnQiCMS) website operations personnel, I am well aware of the importance of content in attracting and retaining users, and the flexible template system is the key to achieving personalized content display.AnQiCMS provides powerful custom template features, allowing operation personnel to create unique page layouts and styles according to different content needs.### AnQiCMS Template Working Principle Overview AnQiCMS template system is based on Go language and adopts syntax similar to Django template engine, files are in the form of `

2025-11-06

What is the default naming rule for single page detail page templates in AnQiCMS?

As an experienced CMS website operator for an enterprise, I am well aware that the exquisite presentation of content lies in the flexible application of templates.AnQiCMS as an efficient and customizable content management system provides us with powerful tools to shape every detail of the website, including the layout and style of single-page detail pages.Understanding the template naming rules is the foundation for efficiently managing and optimizing website content.

2025-11-06

How to create default templates for the model home page, document detail page, and list page of AnQiCMS?

As an experienced security CMS website operator, I am well aware of the importance of a clear and efficient template system for website content management.AnQiCMS provides a highly flexible and customizable template system that allows us to easily create personalized page layouts based on different business needs.Mastering the creation method of its default template is the foundation for efficient operation and content optimization.This article will detail how to create default templates for the model homepage, document detail page, and list page of AnQiCMS, with instructions on the use of key tags

2025-11-06

What is the naming convention for the default homepage template file in AnQiCMS?

As an experienced CMS website operation personnel of an enterprise, I know that the naming specification of template files is crucial for the smooth operation and efficient management of the website.A clear naming convention not only ensures that the system renders the page correctly, but also greatly improves team collaboration and post-maintenance efficiency.Below, I will elaborate on the naming rules of the default home page template files in Anqi CMS.In AnQi CMS, all template files are stored in the `/template` folder under the system root directory.Each independent website template will be in `/template`

2025-11-06

How to get and display the website name and logo in AnQiCMS template?

As an experienced CMS website operation personnel of an enterprise, I am well aware of the importance of effectively displaying brand information in templates for user experience and brand recognition.The following article will provide a detailed guide on how to obtain and display the website name and logo in the AnQiCMS template.In AnQiCMS template, a practical guide to obtaining and displaying the website name and LogoThe website's name and logo are the core visual elements of the brand

2025-11-06

How to call the contact information set in the background of AnQiCMS template?

As an experienced senior personnel proficient in AnQi CMS content operation, I am well aware of the importance of efficient website information management in attracting and retaining users.Especially contact information such as this basic yet crucial information, its unified management and flexible access are the foundation for improving operational efficiency and ensuring the accuracy of information.Below, I will introduce how to call the contact information set in the background of the AnQiCMS template.

2025-11-06

How to dynamically set the content of the `<title>`, `<meta keywords>`, and `<meta description>` tags for AnQiCMS pages?

As an experienced security CMS website operator, I know that website SEO optimization is the core work to attract and retain users, and to enhance the visibility of the website.It is crucial to accurately set the <title>, <meta keywords>, and <meta description> tags for each page (collectively known as TDK, i.e., Title, Description, Keywords).The AnQi CMS was designed with SEO-friendliness in mind from the outset

2025-11-06

How to build a multi-level navigation menu in AnQiCMS template?

Hello, I am the familiar Anqi CMS website operation veteran that you know.Navigation menus are of great importance in daily website maintenance and content optimization, as they are not only guides for users to browse the website but also crucial for search engines to understand the website structure.Today, let's delve into how to build a flexible and efficient multi-level navigation menu in the AnQiCMS template.

2025-11-06