How to customize the template layout of article, product, and category pages?

Calendar 👁️ 79

In Anqi CMS, flexibly customizing the page template layout is a key step to enhance website personalization and user experience.Whether it is an article, product detail page, or category list page, AnQi CMS provides powerful and intuitive tools, allowing you to easily create unique and stylish pages without deep programming.

Let's explore how to bring your design concept to life in Anqicms.

Anqicms template overview

Before starting the custom journey, understanding some basic conventions of the Anqi CMS templates will be very helpful. All template files are stored in the root directory of the website./templateIn the folder, while the styles (CSS), JavaScript scripts, and images, etc., static resources used by the template are placed uniformly in/public/static/Directory.

The AnQi CMS template syntax is concise and efficient, similar to the style of the Django template engine. You will encounter two main markers:

  • double curly braces{{变量}}: is used to output variables or data.
  • single curly braces and percent signs{% 标签 %}:used to implement logic control, such as conditional judgment (if), loop (for) as well as calling specific function tags.

All template files use UTF-8 encoding to ensure correct display of content. Additionally, Anqi CMS supports various website modes, including adaptive, code adaptation, and PC+mobile independent site modes, which means you can create separate templates for mobile content, which are usually stored in the template directory.mobile/In the subdirectory.

Core: Understand the structure and naming conventions of template files

To customize the page layout, you first need to master the location and naming rules of template files. Every set of templates is/templateIt has its own independent directory, which contains oneconfig.jsonfile used to describe the basic information of the template.

The AnqiCMS supports two template organization modes: folder organization mode and flat file organization mode. Whichever one you choose, there are some conventions for default template files:

  • Home:It is usuallyindex/index.htmlorindex.html.
  • Model homepage (such as article or product list homepage): {模型table}/index.htmlor{模型table}_index.html.
  • Document (article/product) detail page: {模型table}/detail.htmlor{模型table}_detail.html.
  • Document (article/product) list page (category page): {模型table}/list.htmlor{模型table}_list.html.
  • Single page detail page: page/detail.htmlorpage.html.

The power of custom templates:

In addition to these default names, the most powerful feature of Anqi CMS lies in its flexible custom template naming capability.This means you can specify a unique template file for a specific article, product, or category page. For example:

  • If you have an article with ID 10 and want a custom layout, you can create a namedarticle/detail-10.htmltemplate.
  • If there is a product category with ID 5, you want its list page to be different, you can createproduct/list-5.html.
  • For a single page like "About Us", you can design apage/about.htmlTemplate, and when creating the single page in the background, set it to the "Single Page Template".about.html.

Next, we will explain in detail how to use these capabilities in modules.

Customize article and product detail page template

Articles and products are all classified as "documents" in Anqi CMS, and they share a flexible content model system.

  1. Create a custom field (if needed):Many times, the default title, content, and other fields may not be enough to display all the information you need.For example, a product may require fields such as "model", "brand", "technical parameters", etc., while an article may require fields such as "author source", "publishing organization", etc.You can enter the backendContent management > Content modelEdit or add a model, then add custom fields to the model.This supports single-line text, numbers, multi-line text, radio buttons, checkboxes, dropdown selections, and various other field types.These custom fields will greatly enrich your content display capabilities.

  2. Specify the template in the background:When you edit or publish a new article or product, you will find a named section in the 'Other Parameters' part of the editing interface“Document Template”The field. Here, you can enter the custom template filename that you have created for this specific document, for examplearticle_special_layout.htmlorproduct_showcase.htmlMake sure that this template file actually exists in your template directory.

  3. Call data in the template:In a custom detail page template (for examplearticle/detail.htmlor custom by youarticle_special_layout.html), you can use various tags to retrieve content.

    • Basic content:
      • Article/Product Title:{{archive.Title}}
      • Article/Product Content:{{archive.Content|safe}}(Note here that|safeA filter that ensures HTML code is parsed correctly instead of being escaped)
      • Thumbnail:<img src="{{archive.Thumb}}" alt="{{archive.Title}}" />
      • Published time:{{stampToDate(archive.CreatedTime, "2006-01-02")}}
      • Views:{{archive.Views}}
    • Custom field:If your content model defines additional fields (for example, if you add a field namedproduct_modelproduct model field), you can call it in the following way:
      • Directly call: `{% archiveDetail with name="

Related articles

Where is the TDK (Title, Keywords, Description) information of the home page set and displayed?

The TDK (Title, Keywords, Description) information on the homepage is crucial for the performance of the website in search engines.It is not only the key for search engines to understand the core content of a website, but also an important basis for users to decide whether to click on a website in the search results page.AnQi CMS is an efficient content management system that provides an intuitive and convenient TDK management function, allowing us to easily optimize the visibility of the website homepage in search engines.

2025-11-07

How to display the multi-language content switch button on the website front end?

On AnQiCMS, it is crucial to display a multilingual content switch button on the website front-end to expand the global user base and enhance the user experience.AnQiCMS with its powerful multilingual support and flexible template mechanism makes implementing this feature intuitive and efficient. ### AnQiCMS multilingual mechanism overview AnQiCMS considered the needs of global content publishing from the outset.Its multilingual support is centered around the "multi-site management" feature.This means that you can create different sites to represent different language versions. For example

2025-11-07

How to configure URL rewrite rules in Anqi CMS to optimize search engine crawling?

In website operation, Search Engine Optimization (SEO) plays a crucial role, and a friendly URL structure is a key factor in improving the performance of a website in search engines.A clear and meaningful URL not only helps search engines better understand the content of the page, but also allows visitors to see the theme of the page at a glance, enhancing the user experience.Traditional dynamic URLs often contain parameters that are difficult to understand, which is not friendly to SEO and users.Fortunately, AnQi CMS provides a powerful static rule configuration function, allowing you to easily optimize the URL structure of your website.

2025-11-07

How to display a custom SEO title on the article detail page instead of the article title?

In content operation, setting the title of the website article detail page is a key link.We often encounter such situations: the content title of the article itself needs to be eye-catching and creative, in order to attract readers' clicks;And the page title required for search engine optimization (SEO) (i.e., the content of the `<title>` tag displayed on the browser tab), is more focused on keyword layout, length control, and search engine friendliness.In AnQiCMS, you can fully flexibly manage these two different titles to ensure both user experience and SEO effectiveness.

2025-11-07

How to get and display the thumbnail or cover image of the article in the template?

The Anqi CMS has always been highly praised for its flexibility in content display, where images act as the core elements to attract users and convey information. How to efficiently and accurately obtain and display the thumbnail or cover image of the article in the template is a focus for many website operators.This article will thoroughly explain the Anqi CMS template mechanism and guide you step by step to master the skills of image calls.How does AnQi CMS intelligently handle images

2025-11-07

How to use the `archiveList` tag to sort and display the most popular article list by views?

How to display the popular article list by using the `archiveList` tag in AnQi CMS?In content operations, clearly displaying popular articles on the website to visitors can effectively improve user experience, guide users to discover more exciting content, and indirectly promote search engine optimization (SEO) through effective content distribution.AnQi CMS provides a powerful and flexible template tag feature, where the `archiveList` tag is the core tool to achieve this goal.

2025-11-07

How to display the second-level or multi-level category list in the navigation bar?

The website navigation is like the skeleton of your website, guiding visitors to browse different parts of the website and find the content they are interested in.A clear and intuitive navigation system is crucial for enhancing user experience and the professionalism of a website.AnQi CMS knows this, providing flexible and diverse solutions to build and manage website navigation, especially for complex navigation structures that need to display two-level or even multi-level classification lists.Today, let's delve deeper into how to set up and display these well-structured category lists in Anqi CMS, making your website navigation stronger and smarter.

2025-11-07

How to correctly render Markdown format in HTML and display mathematical formulas in the article content?

When using AnQiCMS to write articles, we often hope that the content is not limited to plain text or simple rich text, but can support richer formats, especially the convenience brought by Markdown syntax, as well as the indispensable mathematical formulas in scientific and technical content.This not only improves the quality of the content, but also provides readers with a better reading experience.AnQiCMS knows the importance of content diversity, and therefore provides Markdown support in the system.But let these Markdown contents, especially complex mathematical formulas

2025-11-07