How to understand the template file structure of AnQiCMS and effectively manage the display layout of the website?

Calendar 👁️ 60

Manage the display layout of a website in Anqi CMS, the core is to understand its flexible template file structure and powerful tag system.This can not only give your website a unique visual style, but also greatly improve the efficiency of content operation and user experience.

I. Overview of AnQiCMS template basics: the cornerstone of building a website

Imagine that your website is a house, and the template system of Anqi CMS is the design drawings and construction tools for this house.It is based on the efficient backend of Go language, but it adopts syntax similar to the Django template engine for the frontend template, which allows users familiar with web development to get started quickly.

Each AnQi CMS website's 'blueprint' is stored in/templateUnder the directory. Here you can find all the HTML files used to build web pages.And the styles (CSS), scripts (JavaScript), and images, etc., which these pages require, are uniformly stored in/public/static/In the catalog.

In terms of template file writing, AnQi CMS follows some basic conventions: all template files use.htmlUsing as a suffix, and uniformly adopting UTF-8 encoding to avoid garbled characters. Content variables are enclosed in double curly braces{{变量}}Enclosed, while conditional judgment, loop control, and other logical tags are used{% 标签 %}{% 结束标签 %}The clear syntax structure makes the template code easy to read and maintain. In addition, variable names mostly use camel case, which is convenient for you to quickly identify and call.

The AnQi CMS also considers the browsing experience on different devices, supporting various template types: adaptive (a single code fits all devices), code adaptation (different templates for PC and mobile end but sharing the same domain), as well as independent mode for PC and mobile end (different templates for PC and mobile end and bound with independent domain).This flexibility allows your website to present**effect**on both computers and mobile phones.

Understand the structure of template files in depth: follow the map to control the overall situation

To effectively manage the website layout, it is first necessary to have a clear understanding of the template file structure of Anqi CMS.

1. Template directory and configuration file: the 'ID card' of the website

In/templateUnder the root directory, each independent template theme will have its own folder. This folder contains a crucialconfig.jsonfile, which is like the 'ID card' of the template.config.jsonDefined the name, version, description, and the most criticaltemplate_type(Template type: 0 for adaptive, 1 for code adaptation, 2 for computer + mobile end).This configuration item directly determines the display mode of the template on different devices, and it is the first step in your responsive design.Through the "template design" feature on the backend, you can easily view and manage these template themes and edit them online.

2. File organization pattern: Choose the "blueprint" that suits you.

The Anqi CMS provides two main file organization modes to adapt to projects of different scales and complexities:

  • Folder organization mode:This pattern places template files for different functions or types (such as home page, detail page, list page) in their respective subfolders, for exampleindex/index.htmlUsed for the homepage,{模型table}/detail.htmlUsed for content detail page. It also supports placing the header, footer, and other common partsbash.html, placing the sidebar, breadcrumbs, and other small componentspartial/Under the directory, making the structure clearer, easier for large project management and team collaboration.
  • Flattened file organization mode:For websites with a relatively simple structure, you can choose this pattern, placing all major template files directly in the template root directory, such asindex.html/{模型table}_detail.htmlThis approach is more direct, suitable for quickly setting up personal blogs or small enterprise websites.

No matter which mode you choose, some key page names are universal, such as: Home page (index/index.htmlorindex.html)、Content Model Homepage({模型table}/index.htmlor{模型table}_index.html)、Document Details Page({模型table}/detail.htmlor{模型table}_detail.html)、Single page(page/detail.htmlorpage.html)and various error pages(such aserrors/404.html)

3. Mobile Template: Customized for Small Screens

If yourconfig.jsonoftemplate_typeSet to code adaptation or PC+mobile mode, then create one under the template directorymobile/The subdirectory is particularly important. This directory is专门存放存放mobile end templates, and its internal structure is consistent with the main template directory.This means you can provide a completely independent page layout and interactive experience for mobile users, ensuring an optimal user experience on various screen sizes.

3. Refine the website display layout management: make full use of tools, twice the result with half the effort

After understanding the template structure, the next step is to fine-tune the display layout of the website using the powerful features provided by Anqi CMS.

1. Flexible template switching and customization: Assign exclusive appearance to different content

The Anqi CMS allows you to switch the theme of the entire website with one click through the admin management interface, which is very convenient for website redesigns or trying different styles. Even more powerful is that you can specify independent template files for specific parts of the website:

  • Custom category template: When creating or editing a category, you can specify a specific template file for the category and its content list, for example, to set a template for a product categoryproduct/list-tech.htmlto display a unique layout.
  • Custom document template:For a single document, you can specify a special detail page template to use, for example, a download page can usedownload.htmlTemplate.
  • Custom single page template:For a single-page such as “About Us” or “Contact Us”, you can specify a uniquepage/about.htmltemplate to present a personalized design.

These custom template features are implemented through preset file naming rules, you just need to select the corresponding template name in the background, and the system will automatically apply it.

2. Powerful and easy-to-use template tags: the magician of content

The AnQi CMS template tags are your 'magician' for controlling page content and layout. They present complex backend data in a simple and intuitive way on the frontend.

  • Variable and data acquisition: {{变量}}This is the basic usage, used to directly display data such as website names, article titles, etc. from the background.
  • Logical control and content looping: {% if 条件 %}Used to implement conditional judgments, such as displaying different content based on whether the user is logged in;{% for item in 列表 %}It is used to loop through article lists, category lists, etc., to dynamically generate page content.
  • Content block reuse and structural inheritance:
    • {% include "partial/header.html" %}Used to insert commonly used code snippets such as headers, footers, sidebars, etc. into any page, avoiding repeated writing and improving maintenance efficiency.
    • {% extends "base.html" %}: Implement template inheritance, you can create a basic layout (base.html) and other pages can inherit it and rewrite specific areas ({% block content %}) which greatly simplifies template development and modification.
    • {% macro 宏名称(参数) %}: Defines a reusable code macro, similar to a function, that can be called multiple times in a template, especially suitable for building complex and repetitive UI components.
  • : Specific feature tag:The AnQi CMS is built-in with rich tags to simplify various common functions, such as:
    • {% system %}and{% contact %}Tags can help you easily get the global settings and contact information of the website.
    • {% navList %}Tags are used to build

Related articles

What template types does AnQiCMS support to adapt to content display on different devices?

Whether website content can be seamlessly and beautifully displayed on various devices in today's multi-screen era is directly related to user experience and brand image.AnQiCMS as an enterprise-level system focusing on efficient content management, fully understands the importance of this demand, and therefore provides a flexible and diverse range of solutions in template support to ensure that your website content can be presented in a **state** on desktop computers, tablets, or mobile phones.To meet the needs from simple and efficient to highly customized, AnQiCMS meticulously designed three core website modes to handle the display of different devices

2025-11-08

How can I customize the overall interface and user experience of the AnQiCMS website?

A powerful and flexible set of tools is provided by AnQi CMS, allowing users to deeply customize the overall interface and user experience of the website, thereby creating a digital platform that is both beautiful and efficient.A customized website can not only better convey the brand image but also improve visitors' satisfaction and conversion rate through optimized user experience.This will elaborate in detail on how to achieve this goal by using the various functions of AnQiCMS.Flexible content presentation: The foundation of the interface. The website interface first presents the content.AnQiCMS provides high flexibility in content management

2025-11-08

How to use the `cut` filter to remove the `?` symbol and its subsequent parameters from the image URL path to obtain a pure path?

In website operation, the management and display of image resources are crucial.To ensure the website loads quickly, improve search engine optimization (SEO) and optimize the user experience, we often need to handle image URLs.Sometimes, an image URL may carry some parameters, such as version numbers, cropping sizes, or tracking information, which are usually followed by a question mark (`?')`Start. Although these parameters have their specific purposes, in certain display scenarios, we may wish to obtain a pure image path without any parameters.In AnQiCMS (AnQiCMS)

2025-11-08

Can I remove all HTML comments from the user submitted content in the template using the `cut` filter?

In website operation, we often encounter the need to process user submitted content to ensure the neat and standardized display of the website front-end.One common requirement is to remove HTML comments from the content.When users may paste content from various sources, these hidden comments often come along with it, although they are not visible on the page, they may increase the page loading burden, and even affect the layout in some special cases.Users may think of the `cut` filter in AnQiCMS templates, intuitively feeling that it can "cut off" the unnecessary parts. However

2025-11-08

Do I want to use a unique display template for specific articles or categories, does AnQiCMS support this?

In website operation, we often encounter such needs: some articles or categories, due to the particularity of their content or marketing needs, we hope to give them a completely different display style from the rest of the website.This personalized display requirement is particularly important in today's increasingly rich content.So, does AnQiCMS support using a unique display template for specific articles or categories?The answer is affirmative, and it provides powerful and flexible features to support you in achieving this goal.Why do you need a dedicated template?\n\nImagine

2025-11-08

How to use Django template engine syntax in AnQiCMS template to control the content display logic?

AnQiCMS is an efficient content management system developed based on the Go language, its template system uses a syntax similar to Django's template engine, which is undoubtedly an advantage for those familiar with web development to quickly get started and implement powerful content display logic.It allows us to flexibly control the presentation of content at the template level without writing complex backend code.To understand how to use this GoLang implemented Django template engine syntax in AnQiCMS templates to control content display logic

2025-11-08

How can you list the latest articles or products under a specified category in AnQiCMS?

Manage website content in AnQiCMS, often need to display relevant information according to different themes or sections.For example, you may want to display the latest articles under the "Company News" category in some area of the homepage, or show the latest products under the "Hot New Products" category in the sidebar of the product page.AnQiCMS provides flexible and powerful template tags, allowing you to easily implement these content call requirements.Understanding the content organization of AnQiCMS is the key to efficiently utilizing its features.The system distinguishes different types of content through the "content model", such as article models and product models

2025-11-08

What sorting and filtering options does AnQiCMS provide to control the display order of list content?

How to efficiently display and organize content in website operation directly affects the user experience and the efficiency of information transmission.For users who use AnQiCMS, the system provides various flexible sorting and filtering options to help us accurately control the display order of list content. Whether it is articles, products, or other custom content types, they can be presented to visitors in the most business-friendly way possible.The AnQi CMS has given the control of content display order to the user, which is mainly realized through a powerful template tag system and backend management settings.Through these features

2025-11-08