What naming conventions do AnQiCMS template files support to customize the display of specific pages or categories?

Calendar 👁️ 62

In AnQiCMS, in order to achieve personalized display of website pages or categories, we do not always have to write complex logic from scratch, the system provides a very flexible and intuitive template file naming convention.These conventions allow us to create template files with specific names, enabling the system to automatically recognize and apply them, thereby customizing the display of different content types.

First, understanding the basic structure of the template file is crucial. All template files are stored in/templatethe directory and are used uniformly..htmlAs a file suffix. For example, a template named "default" will be located at/template/default/Below. It is recommended to place the static resources such as styles, JavaScript scripts, and images used in the template separately to maintain order and efficiency./public/static/Directory, to keep it organized and efficient.

The strength of AnQiCMS lies in its support for a variety ofDefault convention for custom template names. When the system is rendering the page, it will intelligently search for the existence of template files that match these specific naming rules.If found, they will be used preferentially without any additional configuration on our part.

Specifically, these naming conventions include:

  • Custom template for document detail page: If you want to provide a unique display effect for a specific document, you can name the template file according to{模型table}/{文档ID}.htmlthe format. For example, if your website has aarticle(Article) model, where the ID is100the article requires a special layout, then you can create a namedarticle/100.htmltemplate file. When the user accesses this article with ID 100, the system will automatically load this custom template. The naming convention also applies to product models, such asproduct/201.html.
  • Custom template on the category list page: To make the article or product list of a specific category have a unique style, you can follow{模型table}/list-{分类ID}.htmlnaming format. Assuming yourproduct(Product) There is an ID of5category, you can createproduct/list-5.htmlCustomize the list display of this category. This way, when users browse the product category page with ID 5, they will see this exclusive list layout.
  • Custom template for the single-page detail page.: For common single-page templates like 'About Us' and 'Contact Us', customization is also possible. The naming format ispage/{单页面ID}.html. For example, the ID is1The single page (usually might be "About Us"), you can createpage/1.htmlto define its display style.

In addition to these naming conventions automatically recognized by the system, AnQiCMS also grants website administrators more advancedcustom template specification capabilitiesThis means that even if it does not follow the above naming conventions, website administrators can still manually assign a completely custom template file for specific documents, categories, or even individual pages according to the needs of content operation.

For example, you may want the "About Us" page to have a special designabout-us.htmltemplate instead of the default onepage/{单页面ID}.html. All you need to do is in/template/你的模板目录/page/Createabout-us.htmlThen edit the 'About Us' single page in the background and directly fill in the 'Single Page Template' fieldabout-us.html. AnQiCMS will use the template you specified in the background first when rendering this single page.The same method also applies to the custom template settings for documents and categories.This approach provides great flexibility, able to handle various personalized display needs, such as customizing exclusive templates for specific marketing activity pages, download pages, or partner introduction pages.

On the organization of template files, AnQiCMS supports two modes: "folder organization mode" and "flattened file organization mode". Regardless of which one is chosen, the above naming conventions are universal. In addition, to better adapt to mobile device access, AnQiCMS allows us to create in the template directorymobile/Subdirectory. In thismobile/Under the directory, you can follow the same naming conventions as the PC end to design independent template files for mobile devices, thereby providing differentiated high-quality user experiences on both PC and mobile devices.

By these flexible naming conventions and backend specification mechanisms, AnQiCMS greatly simplifies the complexity of template customization.It enables website operators to efficiently implement highly customized displays for different content types, functional modules, or specific pages, thus attracting users better, optimizing the user experience, and serving specific business goals.


Frequently Asked Questions (FAQ)

  1. Ask: In AnQiCMS, should I prioritize using template naming conventions or manually specifying templates in the background?Answer: It depends on your customization needs. If you just want to provide a dedicated template for a document, category, or single page with a fixed ID and do not want to frequently operate in the background, then follow the naming conventions (such asarticle/100.html)Will be more efficient, the system will automatically recognize. But if your customization needs are more flexible, such as some documents in a category needing one template, and others another, or if you want to specify a general template that is different from the default name for a particular page (such aspromo-page.htmlThen specifying a template file manually in the background will provide greater control. Typically, manually specified in the background has a higher priority than the default naming convention.

  2. Ask: If I created a naming convention template (for examplearticle/100.html), but then manually edited the article in the background to specify another template (for examplespecial-article.htmlWhich template will take effect in the end?Answer: In this case, the template manually specified by the background willspecial-article.htmloverride the naming convention templatearticle/100.htmlThe system will prioritize handling the template file path you explicitly configure in the background content editing interface.The naming convention is more of a convenient default mechanism, while the backend configuration provides finer-grained control and priority.

  3. Ask: Does AnQiCMS support customizing independent templates for mobile pages? How to implement it?Yes, AnQiCMS fully supports customizing independent templates for mobile pages. You just need to create a subdirectory namedmobile/in your current template directory, and thenmobile/Directory naming conventions are the same as on the PC (for examplearticle/100.htmlorpage/1.htmlCreate the corresponding mobile template file. When the website runs in "code adaptation" or "PC+mobile independent site" mode, the system will automatically load according to the user's devicemobile/The corresponding template under the directory.

Related articles

How to include common header, footer, and other code snippets in AnQiCMS templates to unify the display style?

How to include common header, footer, and other code snippets in AnQiCMS templates to unify the display style? When building a website, whether it's a personal blog, a corporate website, or a marketing site, maintaining consistency in page visuals and functionality is crucial.Imagine if each page's top navigation, footer copyright information, and even the sidebar were all different, the user experience would be greatly reduced, and the professionalism of the website would also be greatly reduced.

2025-11-08

How to use the loop (for) tag to traverse and display data lists in AnQiCMS templates?

In AnQiCMS template development, mastering how to effectively display dynamic data lists is the key to building a feature-rich website.Whether it is the latest article, product display, or category navigation, all of these rely on the loop mechanism in the template.AnQiCMS's template system borrows the simplicity and power of Django's template engine, with the `for` loop tag being the core tool for data traversal.### Understanding the basics of `for` loop tags When we need to repeatedly display a series of structurally similar data on the page, the `for` loop comes into play

2025-11-08

How to use conditional judgment (if/elif/else) logic to control the display status of content in AnQiCMS templates?

In the template development of Anqi CMS, effectively controlling the display status of content is the key to achieving high customization and an excellent user experience.Conditional logic, especially the `if`/`elif`/`else` statements, injects intelligence into the template, allowing it to present information flexibly based on different data or situations.A deep understanding and proficient application of these logic will make your website content more dynamic and interactive.

2025-11-08

How to configure AnQiCMS to implement adaptive, code adaptation, or PC+Mobile independent site display mode?

How can websites provide a smooth and consistent user experience across different screen sizes in today's multi-device co-existing internet environment, which is a core challenge for operators.AnQiCMS is well-versed in this field, providing users with flexible and diverse website display mode configurations. Whether your needs are simple and efficient or finely customized, you can find the appropriate solutions. The Anqi CMS currently supports three mainstream website display modes: adaptive mode, code adaptation mode, and PC+Mobile independent site mode.

2025-11-08

How does the `system` tag display the website name, Logo, record number, and copyright information on the AnQiCMS website?

When building and operating a website, the website's name, logo, filing number, and copyright information are important elements that constitute the professional image and legality of the website.They are not only the identity of the website, but also the foundation of user trust.For users of AnQiCMS, the system provides a convenient and efficient way to manage and display these core information, which is through the powerful `system` tag.This article will delve into how to use the `system` tag on the AnQiCMS website to flexibly display the website name, Logo, filing number, and copyright information

2025-11-08

How does the `contact` tag display contacts, phone numbers, addresses, and social media links on the AnQiCMS page?

In website operation, clearly and accurately displaying contact information is crucial for building user trust and promoting communication and interaction.AnQiCMS provides a very convenient way to manage and display this information, that is, through the `contact` tag.This tag helps us easily call the preset contact name, phone number, address, and even social media links on any page of the website, without hard coding, greatly improving content management efficiency.### First step: Configure contact information in the AnQiCMS backend Before we start using `contact`

2025-11-08

How to dynamically generate and display the page's Title, Keywords, and Description in AnQiCMS using the `tdk` tag?

In website operation, Title, Keywords, and Description (abbreviated as TDK) are the foundation of Search Engine Optimization (SEO).They not only describe the page content to search engines, but also directly affect the click intention of users on the search results page.AnQiCMS as a content management system focused on, deeply understands the importance of TDK, and therefore provides a powerful and flexible mechanism that allows users to easily dynamically generate and finely manage the website TDK.### How to manage TDK in AnQiCMS

2025-11-08

How to build and display a multi-level navigation menu using the `navList` tag on the AnQiCMS website?

The website navigation is an important guide for users when they visit the website. It not only helps users find the information they need quickly, but also reflects the clear structure and friendly user experience of the website.In AnQiCMS, building flexible and diverse navigation menus is a relatively simple and efficient task, mainly due to its powerful `navList` tag.Whether it is a simple single-layer menu or a complex two-level dropdown menu, the `navList` tag can provide strong support.### `navList` label

2025-11-08