How to set up independent template files for specific pages or content types?

Calendar 👁️ 64

In website operation, we often encounter situations where we need to design a unique display style for certain pages or content types.Perhaps the product detail page needs a more attractive layout, or some special article needs to break the conventional style to highlight its importance, or a single-page 'About Us' needs to showcase the brand characteristics.AnQi CMS fully understands this personalized demand and provides flexible and powerful template customization capabilities, allowing you to easily set up exclusive template files for different content, thereby achieving more refined content presentation and brand image management.


Flexible and variable template application logic

The way AnQi CMS handles template files is both intelligent and intuitive, mainly through two mechanisms:Automatic recognition with precedence of agreementandManually specified in the background.

1. Priority of convention: Intelligent recognition of template files

In order to simplify the operation, AnQi CMS supports a set of 'agreement first' rules. If you place the template files in accordance with a specific naming format,/templateUnder the directory, the system can automatically recognize and apply them without any additional configuration on your part in the background. This is like preparing a "default skin" for specific types of content.

For example, when you want to use a certain model (such as the "article" model, whose table name may bearticleWhen a specific document or category has its own list page or detail page, you can try the following naming conventions:

  • Specific template for a single document:You can create a document for a specific ID (such as an article with ID 10)article/10.html. If this file exists, the system will automatically call it when accessing the article detail page with ID 10.
  • For the list page template under a certain category:If you have a category (such as an article category with ID 123) that requires a special list display, you can createarticle/list-123.htmlWhen the user visits the list page of this category, the system will prioritize this template.
  • Specific template for a single page:For a specific single page (such as a single page with ID 5), you can createpage/5.html. The system will automatically apply it when accessing the single page.

In this way, for content with clear IDs or specific categorization rules, you can quickly customize its frontend display without delving deeply into the backend to configure each one individually.

2. Specify in the background: accurately control the display of every content

In addition to automatic recognition, Anqi CMS also provides intuitive backend configuration options, allowing you to accurately specify unique template files for almost all types of content.This method offers more flexibility and is more suitable for dealing with complex page requirements.

  • Set an independent template for a single document or product:When you edit a specific article or product, you can find a named part calledDocument TemplateThe field. Here, you can fill in the name of a specific file in the template directory (usually the directory of the current theme), such asdownload.htmlThis means that even if other documents in the same category use the default template, this particular document can have its own unique display style. Make sure that thisdownload.htmlThe file actually exists in the template folder of your current theme.

  • Set a template for a category and all its documents:Enter the "Content Management" under the "Document Category" page, when editing a category, you will see two fields related to the template:

    • Category template:This field is used to specify the template used for the list page of the category (for example, the page displaying all articles under the category). The default may bemodel/list.html, and you can change it tocategory_promo.htmlWait for custom template.
    • Document template:This is a very practical feature. If you want all the documents under this category (new or old) to use the same detail page template, you can fill it in here, for exampleproduct_new_style.html. It is also noteworthy that there is an option to 'Apply to child categories', which, when checked, will inherit the settings downward and apply to all subcategories of the current category.
  • Set an independent template for single page:Edit any single page under "Page Resources" -> "Page Management", and there will also be a "Single page templateThe field. Here, you can specify for 'About Us', 'Contact Us' and other single-page websites.about_us.htmlorcontact_us_with_map.htmlTemplates with exclusive features, thus enabling these static pages to also display rich visual effects and functionality.


Flexible template naming and reference

The template reference mechanism of AnQi CMS is very flexible. Whether you adopt the convention naming or manually specify it on the back-end, you just need to make sure that the path of the template file filled in the back-end (relative to the root directory of the current theme template) is accurate, and the file actually exists.

For example, you can create one under the theme folder.pagecatalog, and place it inabout.htmlThe file contains content specifically designed for the "About Us" page. Then, when editing the "About Us" single page in the background, simply fill in the "Single Page Template" field.page/about.htmlIt is done. The system will locate and render your exclusive template based on this relative path.


Important usage suggestions

  1. Ensure that the template file actually exists:No matter how you specify the template, the most crucial point is that you must have this file in the corresponding theme template folder on the server.If the file does not exist or the path is incorrect, the page will not display normally.
  2. Clear naming conventions:It is recommended to use clear and meaningful names for custom template files, for examplearticle_featured_detail.htmlorcategory_product_showcase.htmlThis helps with future maintenance and management.
  3. Take full advantage of template inheritance and fragments:The AnQi CMS supports Django template engine syntax, which means you can make use of{% extends 'base.html' %}template inheritance to establish a unified website skeleton; at the same time, using{% include 'partial/header.html' %}Introduce reusable code snippets (such as headers, footers, sidebars, etc.). This can greatly improve the efficiency and code reuse of template development.
  4. Be sure to test after modification:After each template setting change, please be sure to visit the front-end page for testing to ensure that everything displays normally.
  5. Understand the priority:In most cases, the most specific settings (such as the template for a single document) take precedence over less specific ones (such as the template for an entire category).

By using the above method, you can easily master the template customization function of Anqi CMS, whether you are pursuing local highlights under a unified style or creating a distinctive special page, you can do so with ease.Let your website content display more vividly, providing users with a better browsing experience.


Frequently Asked Questions (FAQ)

1. Will the custom template I set for a category be inherited by its subcategories?Yes, when you set the "Category Template" or "Document Template" for the parent category on the category editing page, you can select the option "Apply to Subcategories".If checked, this setting will be automatically applied to all subcategories, greatly simplifying the template management of multi-level categories.

2. Can I set different templates for a single document and its category at the same time? Which one will take effect?The finer the granularity set in AnQi CMS,

Related articles

How to customize the display layout and style of AnQi CMS

Customizing the display layout and style of website content in AnQi CMS is an indispensable part of building a website that is both beautiful and efficient.The system provides a rich set of tools and flexible mechanisms, allowing users to fully control the visual presentation of the website from content structure, template selection to detailed style. ### Core Foundation: Flexible Content Model and Custom Backend The display of website content first depends on its inherent structure. One of the advantages of AnQi CMS is that it provides the 'flexible content model' feature.

2025-11-08

How to display different types of data (such as) through the AnQi CMS custom content model?

When building a website, we often encounter situations where the content is not just simple 'articles' or 'products'.The traditional website content management system is often limited to a few predefined content types, which seems inadequate when facing diverse information display needs.AnQiCMS (AnQiCMS) is well-versed in this field, providing you with a powerful tool for easily handling various data displays through its flexible custom content model function.

2025-11-08

How to ensure that watermarks and anti-crawling interference codes are automatically added when images are displayed in the Anq CMS?

In today's era of digital content prosperity, the copyright protection and prevention of content being maliciously collected has become an important issue that every website operator cannot ignore.Handcrafted images and content, without protection, are easily copied by dishonest elements with a single click, not only damaging the creators' labor but also affecting the authority and brand value of the website.

2025-11-08

What website modes (adaptive, PC+Mobile) does AnQi CMS support to display content?

In the era of multi-screen interconnection, how website content adapts to different devices directly affects user experience and the efficiency of information dissemination.AnQi CMS fully considers this requirement, providing users with a variety of flexible website content display modes, ensuring that your website can be presented in **status** on various devices such as PCs, tablets, and mobile phones, bringing visitors a smooth and comfortable browsing experience.The AnQi CMS mainly supports three core modes in content display: adaptive mode, code adaptation mode, and PC+Mobile independent site mode.These three patterns have their own focus

2025-11-08

What template file types and directory structures does AnQi CMS support to organize displayed content?

AnQi CMS provides high flexibility and strong organizational capabilities in content display, which is mainly reflected in its support for template file types and directory structures.Understanding these conventions and mechanisms can help you customize the appearance and content layout of the website more efficiently. ### The core structure and conventions of template files Firstly, AnQi CMS will统一存放 all template files used for front-end display in the root directory of the site under the `/template` folder.Each independent website theme or template set should have its own folder in this directory

2025-11-08

How can you reference common header, footer, or sidebar content in a template?

In the daily operation and maintenance of the website, we often encounter such situations: each page needs to include a unified header, a standard footer, or a fixed sidebar.If every page were to rewrite this content, it would not only be inefficient but also a huge amount of work to modify once.AnQiCMS (AnQiCMS) understands this pain point and therefore provides a flexible and powerful template reference mechanism to help us efficiently manage these common contents, ensuring the unity and maintainability of the website.### Overview of AnQi CMS Template Mechanism In AnQi CMS

2025-11-08

How to correctly render Markdown editor content on the frontend page in HTML?

## AQS CMS Markdown content: How to perfectly present on the front-end page?In content creation, Markdown, with its concise and efficient syntax, has been favored by a wide range of content creators.AnQi CMS knows this and therefore provides strong Markdown editor support.But how can you ensure that the Markdown content you edit in the background is rendered correctly and beautifully on the website's frontend page?Behind this involve several key links, understanding them can help you manage the website content more skillfully.

2025-11-08

How to display mathematical formulas and flowcharts on AnQiCMS web pages?

Today, with the increasingly rich digital content, it often seems inadequate to convey complex information solely through text.Especially in fields such as science, technology, and education, mathematical formulas and flowcharts are the key to expressing rigorous logic and clear steps. 幸运的是,AnQiCMS provides a simple and powerful way to easily integrate and display these professional contents on your web page. This article will introduce in detail how to use the Markdown editor and third-party libraries on your AnQiCMS website to achieve perfect presentation of mathematical formulas and flowcharts.

2025-11-08