How to customize a dedicated content display template for a specific document ID or category ID?

Calendar 👁️ 65

In website operation, we often encounter such needs: a specific product display page needs a unique layout to emphasize its features, or an important event special page needs special design to attract users, or a single page like "About Us" wants to show a different brand character.AnQi CMS provides us with a flexible way to customize exclusive display templates for these unique content needs, thereby greatly enhancing the visual appeal and user experience of the website.

The Anqi CMS template system has adopted the syntax of the Django template engine, with its intuitive and efficient features, providing great convenience for content creators and developers.It supports us in specifying different template files based on content ID (such as a specific article, product) or category ID (such as a category of articles, product column) to ensure that every corner of the website can accurately convey information.

Scenarios and value of custom templates

Why do we need to customize templates for specific content? This is usually due to the following considerations:

  1. Emphasize the core contentFor key products, time-limited activities and other important content, customizing exclusive templates can break the conventional layout and more effectively guide users' attention, promoting conversion.
  2. optimize user experience: Provide the most suitable reading and interaction templates for different types of content, such as using large image layouts for content mainly with images, and focusing on clear layout and code highlighting for technical documents.
  3. Strengthen brand image:On some core pages, such as "About Us", "Contact Us", and other single pages, customized templates can better integrate brand elements and deepen users' impression of the brand.
  4. Adapt marketing strategy: Coordinate with specific marketing activities, quickly switch or launch special page templates with marketing elements to improve operational efficiency.

AnQi CMS through a set of concise template file naming conventions makes this process easy.

Custom document (article/product) detail page template

If you wish to apply a unique layout to a specific article or product detail page, you can specify it by editing the document in the background under the "Other Parameters" field in the "Document Template" field.

Before specifying the template, you need to create this special template file. Anqi CMS stipulates that the custom template files for document details should be placed in/templateThe corresponding model folder under the catalog. For example, for the article model, it is usuallyarchivefolder; for the product model, it isproductfolder. The file naming format is{模型table}/{文档ID}.html.

For example, if the ID of an article document you have is123and the model table name isarchive, you can create a template file namedarchive/detail-123.html. Alternatively, if you have a product ID of456The product namedproductYou can createproduct/detail-456.html.

In these customized template files, you can still use as in the general template, you can usearchiveDetailTags or go through directly{{archive.Title}}In order to call various detailed information and custom fields of the current document to build the unique display effect you expect.

Customized category (column) list page template

For a specific category (such as the list page under the "News Dynamics" column, or the product list under the "Latest Products" category), you may wish to have a different list display style than other categories.AnQi CMS allows you to customize a dedicated list template for each category.

Similarly, you need to/templateCreate a template file in the corresponding model folder under the directory. The naming format of the category list page is{模型table}/list-{分类ID}.html.

For example, if there is an article category ID is10, the model table name isarchiveYou can createarchive/list-10.htmlFile. If there is a product category ID of20, the model table name isproduct, then it can be createdproduct/list-20.html.

After creating the template file, log in to the Anqi CMS backend, go to the "Content Management" under the "Document Category" page, and edit the corresponding category. In the "Other Parameters", find the "Category Template" field, and fill in the name of the template file you created (for examplelist-10.htmlIt is worth mentioning that there is also an option to apply to subcategories. If you check it, all subcategories under this category will automatically inherit this custom template, saving the trouble of repeating the setting for each subcategory.

In these custom category list templates, you can usecategoryDetailtags to obtain the detailed information of the category itself and combinearchiveListLabels to display the document list under the category, achieving various complex layouts and functions.

Custom single page template

The single-page feature of Anqi CMS is very suitable for creating independent pages such as "About Us", "Contact Us", "Terms of Service", etc.If you want a single page to have a completely independent visual design, you can also customize a dedicated template for it.

The template files for single-page layouts are usually located in/template/page/the directory. The file naming format can bepage/{单页面ID}.htmlor more flexibly, usepage/{自定义URL别名}.htmlFor example, if you have a single page with an ID of1Can createpage/1.htmlIf your "About Us" page is set up with a custom URL alias in the backendabout_usThen you can createpage/about_us.html.

When editing a single page in the background, enter the name of the template file you created in the "Single Page Template" field (such asabout_us.html),The system will load the template you specified when accessing this page. Within the template, you can usepageDetailtags to obtain the title, content, images, and all other information of a single page.

The storage of template files and basic structure

All customized template files should be stored in the root directory of the website/templateIn the folder. If you have enabled the mobile adaptation mode and need to customize the template for mobile, you should place the mobile template file inmobileThe internal structure is consistent with the PC template in the subdirectory.

All template files should use.htmlAs a suffix, and use UTF-8 encoding uniformly to avoid garbled characters issues. The Anqi CMS template system is based on Django style, which means you can use variables flexibly in templates ({{变量}}), conditional judgments ({% if ... %}), loop ({% for ... %}) and various built-in tags and filters to build rich pages.

Practical skills for customizing templates.

When customizing templates, in addition to the above method of creating exclusive template files, there are some practical skills that can help you work more efficiently:

  • Flexibly apply conditional judgment: For some pages that only require minor adjustments, it is not necessary to create a completely new template file. You can use the generaldetail.htmlorlist.htmltemplate, by using `{% if

Related articles

What is the default template file name for the document detail page and list page?

When using AnQiCMS for website building and content management, understanding the naming conventions of its template files is crucial for customizing and optimizing the website appearance.AnQi CMS to simplify template management, provides a flexible and default recognition naming convention, allowing website developers and operators to work more efficiently.First, all template files should be unified to use the `.html` suffix and placed in the `/template` folder under the website root directory.the styles and JavaScript scripts used in the template

2025-11-08

How can we design and display a separate content template for mobile devices to optimize the mobile user experience?

It is crucial to optimize the mobile user experience for modern website operations, and designing content templates specifically for mobile devices is an efficient way to achieve this goal.AnQi CMS provides a flexible mechanism, allowing users to provide the most suitable browsing experience for different terminals according to their needs.### Understanding AnQi CMS Mobile Template Mode AnQi CMS is designed to meet the diverse mobile adaptation needs and includes three main website modes that determine how content is displayed to mobile users: * **Responsive Template Type**

2025-11-08

What template types does AnQiCMS support to adapt to the display of content on different devices?

In today's digital world, users access websites through various devices, which has become the norm.From wide PC monitors to palm-sized smartphones, how to present website content seamlessly and efficiently is a challenge that every operator must face.AnQiCMS deeply understands this, providing users with a variety of flexible template adaptation strategies to ensure that your website can display the effect on different devices.AnQiCMS mainly supports three template types to adapt to the content display of different devices, each type has its unique application scenarios and advantages, and you can choose according to your own business needs and operational strategy

2025-11-08

How to customize independent display templates for different categories or single pages?

In website operation, we often hope to design unique display styles for different content types or specific pages.For example, a news article may require a concise and clear list style, while a product introduction may focus more on images and detailed specifications;The "About Us" page often requires a separate design to reflect the brand image.AnQiCMS (AnQiCMS) fully understands the importance of these personalized needs, providing flexible template customization features that allow you to easily create a unique visual experience for different parts of the website without delving into code.Security CMS based on Go language development

2025-11-08

How to retrieve and display the system configuration information of the website in the template?

In website operation, we often need to display some global website information, such as the website name, Logo, filing number, copyright statement, as well as custom contact information or social media links.This information, if directly hardcoded in the template, would require searching and updating each page whenever a modification is needed, which is time-consuming and prone to errors.The AnQi CMS provides a very powerful and convenient template tag —— the `system` tag, which allows these system configuration information to be dynamically obtained and displayed in the template, greatly enhancing the maintainability and operational efficiency of the website.###

2025-11-08

How to display contact information on the page, such as phone number, address, etc.

The contact information of the website is an important part of establishing user trust and providing convenient services.Whether it is displaying a simple phone number at the bottom of the website or providing detailed addresses and social media links on the "Contact Us" page, Anqi CMS offers a flexible and efficient way to manage and present these key information.This article will delve into how to set up and display all the contact information on your website using Anqi CMS, ensuring that your customers can easily find you.### Backend Management:Unified setting your contact information In AnQi CMS

2025-11-08

How to dynamically display SEO titles, keywords, and descriptions (TDK) on different pages?

In website operation, Search Engine Optimization (SEO) is a key element in enhancing website visibility.Among them, the page title (Title), keywords (Keywords), and description (Description), abbreviated as TDK, play a crucial role.They are not only the primary information that search engines understand the content of the page, but also an important factor in attracting users to click.In AnQiCMS (AnQiCMS), we can easily implement the dynamic display of TDK, allowing each page of the website to have appropriate and attractive TDK information

2025-11-08

How to build and display a multi-level navigation menu for a website?

Website navigation, like the skeleton and compass of a website, it guides visitors to explore the website content, and is the core of user experience and information architecture.A clear and accessible navigation menu that not only helps users find the information they need quickly, but is also crucial for search engine optimization (SEO).AnQiCMS (AnQiCMS) is well-versed in this, providing powerful and flexible navigation management features that allow you to easily build and display multi-level navigation menus.Next, we will delve deeper into how to build and display your website navigation step by step in Anqi CMS.--- ### One

2025-11-08