How to specify a specific display template for the homepage, detail page, list page, etc. of the AnQiCMS website?

Calendar 👁️ 56

When building a website, we often need to assign unique appearances and functions to different page types, such as the grand layout of the homepage, the immersive reading experience of the article detail page, or the filtering and display of the product list page.AnQiCMS provides a flexible mechanism that allows users to easily specify and manage display templates for each page of the website.This has greatly enhanced the customization of the website, as well as greatly optimized the user experience and content presentation efficiency.

The template files of the AnQiCMS website are stored in/templatethe directory. Typically, each independent website theme will have a dedicated folder in this directory, such asdefaultormy_custom_themeIn this theme folder, static resources such as CSS stylesheets, JavaScript scripts, and images will be stored separately/public/static/In the directory. Template files are usually named with.htmlAs a suffix.

AnQiCMS provides two main ways of organizing template files:Folder organization modeandFlat file organization mode. Regardless of which mode is used, the system supports a set of default template naming conventions. As long as you create template files according to these conventions, AnQiCMS can automatically recognize and apply them without any additional backend configuration. For example:

  • Home page template: Usually named asindex/index.html(Folder mode) orindex.html(Flattened mode).
  • Document detail pages (such as articles, products): Default can be named{模型table}/detail.html. For example, if it is an article model, it can bearticle/detail.html.
  • Document list page (by category): Default can be named{模型table}/list.htmlFor example,article/list.htmlUsed for article list.
  • a single page detail page: Default can be namedpage/detail.html.

Moreover, AnQiCMS also allows specifying a more detailed default template name for specific content, for example:

  • Specific document detail page:{模型table}/{文档id}.htmlThis allows you to design a dedicated template for a specific ID document.
  • Specific category list page:{模型table}/list-{分类id}.htmlYou can provide a customized layout for a list page under a specific category.
  • Specific single page:page/{单页面id}.htmlIt is used to provide a unique template for a specific ID's single page (such as the 'About Us' page').

These default naming rules greatly simplify template management, and according to these conventions, you can create templates as needed for most scenarios.

However, when you need to fine-tune the display template of a specific content (such as a special article, a specific product category, or a unique single page), AnQiCMS also provides an option to manually specify it in the backend management interface.

Specify the display template for a single document (article/product):

When you create or edit a document in the background, you can find a field named "Document Template" in the "Other Parameters" settings area of the document. Here, you can enter the custom template filename you want to use for the document, for exampledownload.htmlMake sure this file exists in your theme template directory, otherwise the document may not be accessible.This approach is very suitable for providing independent layouts for content with special display requirements (such as software download pages, special event pages).

Specify the display template for document categorization:

Under the 'Content Management' module in the background, enter the 'Document Classification' management interface. When you add or edit a category, there are two important template settings in the 'Other Parameters' area:

  1. category templateThis refers to the category underlist pageThe template used. By default, it might be{分类模型}/list.html. If you want to design a unique layout for a specific category's list page, you can enter a custom template filename here, for examplespecial_products_list.html.
  2. Document Template: This setting allows you to set for the list under the categoryAll document detail pagesSpecify a unified template. For example, if you want all products under a certain product category to use a template namedproduct_detail_v2.htmlThe template to display, you can set it here. There is also an option called 'Apply to Subcategories', if checked, the setting will be inherited by all lower-level subcategories.

Specify the display template for the single page:

In the 'Page Resources' module's 'Page Management', when you add or edit a single page, you will see an option for a 'Single Page Template'. Similar to the document, you can specify the custom template file used by this single page here, for exampleabout_us.html.

Understand template types and mobile adaptation:

AnQiCMS supports various website modes, including adaptive, code adaptation, and PC+mobile independent site modes. If your website template selects the "code adaptation" or "PC+mobile independent site" mode, then you also need to create a file in the theme folder.mobileDirectory. The directory structure and file naming conventions of the mobile template are consistent with the PC end, but they exist onlymobilein the subdirectory, for the adaptation of mobile device access.

By these methods, whether through default naming conventions or manual specification in the background, AnQiCMS gives you a high degree of flexibility to finely control the display templates of each page on the website, thereby creating a truly business and brand image website.


Frequently Asked Questions (FAQ)

  1. Q: Why did I specify a custom template file name in the background, but encountered an error when accessing the page, indicating that the template file does not exist?

    • A: This is usually caused by the mismatch between the specified template filename and the actual file path. Please check:
      • Does the template file indeed exist in the current topic's/template/你的主题文件夹/directory.
      • Is the filename spelled correctly (including case).
      • If your template file is in a subdirectory (for examplepage/about.html), make sure to include the subdirectory path when filling in the background.page/about.html.
      • Please confirm that the website theme you are currently using is the one you expected, and that the theme is enabled correctly.
  2. Q: How to distinguish between PC and mobile end templates used by AnQiCMS?

    • A: AnQiCMS supports 'code adaptation' and 'PC+mobile independent site' modes to achieve mobile adaptation. In these modes, you need to create a folder namedmobileThe subdirectory. When the system detects that the user accesses through a mobile device, it will try to find the corresponding template file in that directory first. For example, if the PC detail page template ismobiledirectory to find the corresponding template file. For example, if the PC detail page template isarticle/detail.htmlSo the corresponding template for the mobile end should be placed inmobile/article/detail.html.
  3. Q: Can I reference another template file in a template file? For example, all pages use the same header and footer.

    • A: Of course. AnQiCMS's template engine supports{% include "partial/header.html" %}and{% extends "base.html" %}TagsincludeTags are used to embed other template fragments (such as page headers, footers, sidebars), andextendsTags are used to implement template inheritance, you can create a basic skeleton template such asbase.html),then let other page templates inherit it and overwrite specific blocks. This can greatly improve the maintainability and reusability of the template.

Related articles

How to achieve consistent content display in the `bash.html` and `partial/` public code files of the AnQiCMS template?

In website operation, maintaining consistency in content display is the key to improving user experience, strengthening brand image, and simplifying maintenance work.AnQiCMS (AnQiCMS) provides a powerful mechanism in template design, through the `bash.html` file and `partial/` directory, etc., public code structure, helps operators easily achieve the unified and efficient management of the entire site content display.Imagine your website as a meticulously constructed house.To ensure the overall beauty and functionality of the house, we will not redesign the doors and windows or the roof in every room. Instead,

2025-11-08

How does the `template_type` field in `config.` control the overall display mode of the AnQiCMS website?

In the AnQiCMS world, each template has a configuration file like an ID card - `config.`.It not only records the basic information of the template, but also carries a crucial setting, that is, how to determine the presentation of your website on different devices.This setting is the `template_type` field.### Explore `config.`: The 'manifesto' of the template When creating or selecting a template for an AnQiCMS website

2025-11-08

How does AnQiCMS automatically apply the display style of a specific category or page through the default custom template name?

In the daily use of AnQiCMS (AnQiCMS), the flexibility of templates is one of the key factors in improving content operation efficiency.For many website managers, how to make specific content - whether it is an article, a product, a category page, or an independent single page - have a unique display style while avoiding cumbersome repetitive configuration is a common requirement.AnQi CMS solves this problem through a clever default custom template naming mechanism, enabling efficient collaboration between content operations and front-end design.### AnQiCMS

2025-11-08

How to implement separate mobile content display and adaptation in the AnQiCMS `mobile` template directory?

In today's mobile internet era, the mobile experience of a website has become an important standard for measuring its professionalism and user-friendliness.With the popularity of smartphones and tablet devices, there is an increasing demand for users to access website content smoothly on various screen sizes.AnQiCMS (AnQi CMS) deeply understands this trend and provides flexible and diverse mobile adaptation solutions, among which the design of the `mobile` template directory is the core secret to creating a dedicated mobile experience.###

2025-11-08

How does AnQiCMS's flat file organization pattern simplify template management and optimize the content display process?

In website operation, template management is a key link that balances efficiency and experience.A well-designed, easy-to-maintain template system that can greatly enhance the speed of website content publishing and the flexibility of page updates.AnQiCMS provides unique solutions in this field, especially its 'flat file organization mode', which brings practical convenience to users in simplifying template management and optimizing the content display process.### Say goodbye to layered nesting: The charm of AnQiCMS flat file organization In many traditional content management systems, template files are often buried deep in a multi-level directory structure

2025-11-08

How to customize independent display templates for single pages such as 'About Us' to meet specific display requirements?

In Anqi CMS, in order to make single pages like "About Us" and "Contact Us" have unique display effects, rather than following the unified page layout of the website, we can customize independent display templates for them.This customized capability is a reflection of the flexibility of Anqi CMS, which can help us better shape our brand image, or provide a more suitable display form for specific content.### Overview of AnQi CMS Template Mechanism The AnQi CMS template system is designed to be very intuitive and powerful, based on syntax similar to the Django template engine, which separates the presentation of content from logical control.

2025-11-08

How to use the various tags built into AnQiCMS to retrieve and display the system information, content list, and details of the website?

How to efficiently display various information when building and managing a website is the key to user experience and operational efficiency.AnQiCMS With its flexible and powerful template tag system, enables content creators and website operators to easily control the acquisition, display, and personalized customization of website content without a deep programming background.This article will delve into the rich tags built into AnQiCMS, showing you how to cleverly use them to retrieve and display the system information, content list, and diverse content of detail pages of the website.Understanding AnQiCMS

2025-11-08

How does the `archiveList` tag control the display quantity, sorting method, and pagination logic of the document list?

In AnQi CMS, the `archiveList` tag is undoubtedly a core tool for content display, providing great flexibility and control for the website's content list.Whether you want to display the latest articles on the homepage or implement complex filtering and pagination on the category page, `archiveList` can help us present content accurately through its rich parameter configuration.Next, let's delve into how to use this tag to control the display quantity, sorting method, and the implementation of exquisite pagination logic of the document list.### Control Document Display Quantity

2025-11-08