How to customize the display layout of content on the frontend page in Anqi CMS?

Calendar 👁️ 79

AnQiCMS (AnQiCMS) as an efficient and flexible content management system, its powerful template functions and content model provide us with great freedom. We can finely control the layout of content displayed on the front-end page according to the actual needs of the website.To achieve this goal, we need to deeply understand the template engine, content model, and built-in tags of Anqi CMS.


Core elements of layout customization in AnQi CMS

Customize content layout in Anqi CMS, mainly focusing on the following core elements:

  1. Powerful template engine:The AnQi CMS uses a template engine syntax similar to Django, making template creation intuitive and easy to learn. It uses double curly braces{{变量}}Call variables, use single curly braces and percent signs{% 标签 %}Control logic (such as conditional judgment, loop), we can flexibly display background data on the front end.
  2. Flexible content model with custom fields:The content model function of Anqi CMS is particularly powerful, allowing us to flexibly define various content types according to business needs, such as articles, products, news, etc.Each content model can be configured with exclusive custom fields (such as the 'author', 'source' of articles, the 'price', 'inventory' of products, etc.), which are the key to realizing personalized content display.
  3. Diverse template files and naming conventions:All template files are stored in/templatethe directory, and.htmlWith suffix. Anqi CMS has preset a series of template file naming conventions, for example:article/detail.htmlfor the article detail page,product/list.htmlFor product list pages,page/detail.htmlUsed for single page details. In addition, it supports creating custom template files for specific document ID, category ID, or single page ID, for examplearticle/detail-10.htmlThis is specifically used for the article detail page of ID 10. These naming rules and custom features provide us with great flexibility.
  4. Rich built-in tags and filters:The AnQi CMS is built-in with dozens of template tags and filters for dynamically retrieving and processing various data. For example,archiveListtags are used to retrieve articles or product lists,archiveDetailTags for getting detailed information of a single article,categoryListandcategoryDetailUsed to get the category information,pageDetailFor getting information of a single page, as well as,systemTags for getting system configuration,navListGetting navigation data, etc. With the cooperation of,forloop tags andifConditional tags, as well as,safe/truncatecharsWith filters, we can precisely control the output format and style of content.

Practical Guide: Customizing Your Website Layout in Layers

After understanding the core elements, we can customize the website layout layer by layer according to the 'from macro to micro' approach:

The first layer: Global skeleton - building and inheriting the general template

Websites usually have some common structures, such as headers (Header), footers (Footer), and sidebars (Sidebar). In AnQi CMS, we can use template inheritance (extends) and include (includeBuild these global skeletons.

  • Create a basic template (base.html):In/template/你的模板目录/Create one belowbase.htmlFile, as the master template for all pages of the website. In this file, define the HTML structure, include public CSS/JS, and use{% block 区域名称 %}{% endblock %}tags to define replaceable content areas, such asblock title(Page Title),block header(Header),block content(Main Content) andblock footer(Footer).
  • Contains common fragments:For page header navigation, sidebar, and other independent modules that appear repeatedly on multiple pages, they can be divided into independent template fragments (for example,partial/header.html/partial/footer.html),thenbase.htmlpass through{% include "partial/header.html" %}This is the way to introduce. This helps with code reuse and maintenance.

Second level: Model and classification level - definition of batch content layout

For content of a specific type (such as all articles) or content under a specific category, we need to define unified layout rules.

  • Content model level template:AnQi CMS will prioritize searching for template files under specific content models. For example, all article list pages will use the default template.article/list.htmlSimilarly, all product detail pages will use the default template.product/detail.html. You can create or modify these template files according to these conventions to achieve unified layout at the model level.
  • Category-level customized template:If the content under a category (such as the "Company News" category) needs to be different from other categories (such as "Industry Dynamics"), you can specify a "category template" or "document template" in the "other parameters" when editing the category in the background.
    • Category template:When you specify a "category template" (such asnews_list.html), then the list page of this category and its subcategories will use this custom template instead of the default onearticle/list.html.
    • Document template:When you specify a "document template" (for examplenews_detail.html), then all document detail pages under this category and its subcategories will use this custom template instead of the default onearticle/detail.htmlIn this way, you can easily achieve differentiated display for different content groups.

You will use these templates extensively.archiveList/archiveDetail/categoryDetailUse tags to dynamically retrieve content data. For example, on an article list page (article/list.html) you can use{% archiveList archives with type="page" limit="10" %}to retrieve the article list, and useforLoop through the display.

The third level: content item level - meticulously crafted for personalized display

For content items with special display requirements, Anqi CMS also provides flexible customization options.


Related articles

How to efficiently organize and reference common page header, footer, and other code snippets in the front-end page template?

Manage front-end page code in AnQi CMS, especially the header, footer, and other code snippets that need to be repeated on multiple pages, which is a key to improving development efficiency and website maintainability.AnQi CMS provides a powerful and flexible template engine, allowing us to organize and reference these common codes in an elegant way. ### The Importance of Template Reusability Imagine if your website has dozens, even hundreds of pages, each of which independently contains the complete header, navigation, and footer code. When the website's logo needs to be replaced, or the footer copyright information needs to be updated

2025-11-08

What are the common variable naming and tag syntax rules (such as `{{variable}}` and `{% tag %}`) when making AnQiCMS templates?

To create templates in AnQiCMS and master its variable naming and tag syntax rules is the core.The system is developed based on the Go language, the template engine borrows the syntax style of Django and Blade, making content output and logical control very intuitive.When you are doing template development, you will mainly encounter two basic syntax structures, each of which has different responsibilities.### Core grammar structure: variable output and logical control First are double curly braces `{{ variable }}`, which have a very direct function

2025-11-08

How does Anqi CMS template support adaptive, code adaptation, and independent display mode on PC and mobile?

How to ensure that the website can provide a high-quality user experience on different devices is a challenge that cannot be ignored in today's content marketing and website operations.AnQiCMS (AnQiCMS) knows this, therefore it provides flexible and diverse adaptation modes in template design and content display, allowing users to easily deal with various terminal access scenarios according to their own needs.

2025-11-08

How to set up independent display template files for specific articles or categories?

In the daily operation of websites, we often encounter such situations: some articles are in-depth reports, some are promotional pages for events, and some are corporate profiles or product details.They each have unique display requirements, and if they all follow the website's general template, it may seem monotonous and fail to fully exert the appeal of the content.AnQi CMS is an efficient and flexible content management system that fully considers this personalized demand, allowing us to set independent display template files for specific articles, categories, even single pages, making the content display more tailored and impactful.

2025-11-08

How to implement independent templates for different pages (such as articles, products, single pages) in Anqi CMS?

In website operation, we often need to adopt completely different layouts and design styles for different types of content, such as a deep article, a product display page, or an 'About Us' single page.This differentiated display not only enhances user experience, but also helps content better convey information and achieve marketing goals.AnQiCMS (AnQi CMS) provides a very flexible and powerful solution in this regard, allowing us to easily implement independent templates for different pages.

2025-11-08

How to configure Anqi CMS to support responsive design or independent mobile content display?

In the era of co-existing multiple devices, websites that can adapt well to various screen sizes, whether PC, tablet, or mobile phone, have become a basic requirement.AnQiCMS (AnQiCMS) understands this and provides a variety of flexible configuration options to help you easily implement responsive design or independent mobile content display, ensuring that your content brings users a high-quality browsing experience on any device.The Anqi CMS provides three main website modes to support multi-terminal display: adaptive, code adaptation, and PC+mobile independent sites

2025-11-08

How to dynamically retrieve and display an article list through template tags in Anqi CMS?

Dynamic display of website content is one of the core elements of modern website operations, which not only enhances user experience and allows visitors to easily find the information they are interested in, but also effectively assists in search engine optimization (SEO), making the website more favored by search engines.In Anqi CMS, through the powerful template tag function, we can very flexibly obtain and display various types of article lists.The AnQi CMS template system has adopted the syntax of the Django template engine, with a natural and smooth style, making it very quick for you who are familiar with frontend development.

2025-11-08

How to filter and display specific content lists based on categories, modules, or recommended attributes?

When using AnQi CMS to manage website content, we often need to display specific content (such as articles, products) in the form of a list in different areas of the website.This may mean that we need to display the latest headline articles on the homepage, only show products from a specific series on the product category page, or recommend some popular content in the sidebar.AnQi CMS provides flexible tags, allowing us to accurately filter and display the content list we need based on various conditions such as categories, content models, or recommendation attributes.

2025-11-08