How to specify an independent template file for content display for a specific category or single page?

Calendar 👁️ 70

In a content management system, we often need to present certain content of the website in a unique way, which not only meets the specific needs of branding or marketing, but also brings visitors an optimized browsing experience.AnQi CMS is well-versed in this, providing flexible template customization features, allowing us to easily specify a unique template file for a category page, or even a single content page.

Why do you need to customize a template for a specific page?

Imagine that your "About Us" page might need a special layout that includes team photos and a timeline of the company's development history, rather than simply displaying articles.Or, a product series category page where you want to display it in a grid with tag filtering, rather than the traditional list layout.Or perhaps, some thematic articles require special visual effects or interactive elements to attract readers.

The template customization feature of AnQi CMS is designed to meet these personalized needs.It allows you to break away from the same old layout, customizing exclusive display templates for key categories or single pages on the website, thereby enhancing the professionalism and user experience of the website.

Template file storage and basic conventions

Before starting customization, we need to understand the basic storage location and some conventions of the Anqi CMS template files. All template files are uniformly stored in the site's/templatethe directory and use.htmlAs a file suffix. Each independent template theme will have its own subdirectory, which contains aconfig.jsonFile description theme information.

The AnQi CMS template engine is similar to Django, variables are used with double curly braces{{变量}}While conditional judgments, loop controls, and other logical tags use single curly braces and percent signs{% 标签 %}This provides us with powerful flexibility to build the page structure.

How to specify an independent template for category pages?

When you want to apply a unique layout to a specific document category page (such as a news list page or a product list page), you can follow the following steps:

First, create a new template file in the directory of the current template theme you are using. For example, if you have a product category with an ID of10and you want it to have a specialproduct-grid-list.htmlTemplate display, you can place it intemplate/您的主题名称/product/product-grid-list.html. Here,productThe corresponding directory of your content model (such as product model).

Next, log in to the AnQi CMS backend and go to the "Document Classification" under "Content Management".Find the category of the custom template you want, click edit.At the bottom of the editing page, you will find a collapsible area named "Other Parameters", expand it.Here, you will see a 'category template' input box.

Enter the relative path and name of the template file you just created, for exampleproduct/product-grid-list.html. If you want this custom template to be inherited by all subcategory pages under it, remember to check the 'Apply to Subcategories' option.

Finally, save the category settings. When visitors visit this category page, AnQi CMS will automatically call the one you specifiedproduct-grid-list.htmlto render the content.

In addition, if you want all documents (detail pages) under this category to use the same specific template, you can also find the 'Document Template' field below 'Category Template' to set it.

How to specify an independent template for a single page?

The process of customizing a template for independent single pages like 'About Us' and 'Contact Us' is also simple and intuitive.

The first step is also to create a template file for a single page in the directory of your current theme. Suppose you want to create one for the page with ID5to create a "About Us" page.about-us.htmlTemplate, you can place it intemplate/您的主题名称/page/about-us.html.

Then, enter the AnQi CMS backend, navigate to 'Page Resources' under 'Page Management'.Find the custom single page you want, click edit.On the page editing interface, you will also see a 'Single Page Template' input box.

Enter the custom template filename here, for examplepage/about-us.htmlAfter saving the settings, when you visit this single page, the system will use the one you specifiedabout-us.htmlThe template is used to display its content.

How to specify an independent template for a single document (article/product)?

In addition to categories and single pages, Anqi CMS even allows you to specify independent display templates for specific articles or product content.

When you publish or edit documents (articles or products) under "Content Management

Here, you can enter the path of the template file prepared for this specific document, for examplearticle/unique-article-detail.htmlThis is very useful in handling some high-quality content with special display requirements, such as a deep report with multimedia elements, or a product display page that requires special configuration.

Some important notes and **practices:

  • The template file must exist:No matter where you specify a custom template, make sure that the file actually exists in the template theme directory structure you are using.If the file does not exist, the system will usually revert to the default template or report an error.
  • Use relative paths:When filling in the template name in the background, please use a relative path to the root directory of your current theme, for examplearticle/list-download.htmlinstead ofdownload.htmlor/template/您的主题/article/list-download.html.
  • Start from an existing template:When creating a custom template, a good habit is to first copy the existing default template that is closest to your needs (such asarticle/detail.htmlorpage/detail.htmlThen on this basis to make modifications. This can save the time of building the basic structure from scratch.
  • Using template inheritance:AnQi CMS template engine support{% extends 'base.html' %}This inheritance syntax. This means that your custom template can inherit the main template (such asbase.html) the common structure, only modifying the specific{% block %}The area has greatly improved development efficiency and consistency of templates.
  • Consider mobile adaptation:If your website uses "code adaptation" or "PC+mobile" mode, and the custom template needs a different layout for mobile devices, remember to do so in the theme'smobileCreate corresponding mobile template files under the subdirectory and maintain a similar filename and path structure as the PC template. For example, the PC side ispage/about-us.html, and the mobile side might bemobile/page/about-us.html.

By these flexible template customization features, Anqi CMS allows content display to be unrestricted by a single layout. You can fully express your business needs and creativity, creating a unique and captivating visual experience for the website.


Frequently Asked Questions (FAQ)

1. What will happen if the custom template file I specified does not exist?If you specify a custom template file in the background but the file does not exist in the actual template directory, Anq CMS will usually revert to the default template for the type of content (such as articles, categories, single pages) for display. For example, if an article specifies a non-existent template, the system will try to use{模型table}/detail.html.Although this does not cause the page to crash, you will find that the page layout is not the customized effect you expected.Therefore, after saving the settings, be sure to check the front-end page to confirm that the template is applied correctly.

2. Can my custom template inherit or reuse the default template's header, footer, and other common parts?Of course! The Anqi CMS template engine supports{% extends 'your_base_template.html' %}Such an inheritance mechanism. You can use it at the beginning of a custom template.{% extends 'base.html' %}(or any base template path you define), and then only{% block content %}Write your custom content in the specified area.This way, you don't have to rewrite the header, navigation, footer, and other common elements of the website, just focus on the layout and style of specific pages, greatly improving development efficiency and the unity of the overall style of the website.

3. Does using a custom template affect the SEO of the website?The custom template itself usually does not directly affect SEO ranking.SEO focuses on the content quality of the page, structured data, loading speed, mobile friendliness, URL structure, and metadata (TDK), etc.If your customized template can optimize these factors, such as improving page loading speed, enhancing user experience, ensuring clear content structure, setting up TDK tags correctly, and supporting mobile adaptation, then it will have a positive impact on SEO.On the other hand, if the template is not designed properly, it may lead to slow page loading, disorganized structure, or incompatibility with mobile devices, which could have a negative impact on SEO.The key is in the content and technical implementation of the template, not the behavior of 'customization' itself.

Related articles

How to display a second-level dropdown menu in the navigation menu and associate different content?

AnQi CMS provides a直观and powerful navigation menu management system, allowing you to easily build a clear, user-friendly navigation structure for your website, including multi-level dropdown menus.This not only improves the user experience of the website, but also helps search engines better understand the hierarchy of your website content, thus optimizing SEO performance. ### Understanding the navigation system of Anqi CMS In Anqi CMS, the settings and management of the navigation menu are concentrated in the "Website Navigation Settings" function in the background.This is the core area where you build your website menu

2025-11-09

How to loop through and display all subcategories under a specified category in a template?

How to elegantly display all subcategories under a specified category in Anqi CMS template?For a content-rich website, a clear classification structure is the key to improving user experience and search engine friendliness.AnQiCMS (AnQiCMS) takes advantage of its flexible template engine and powerful tag system, allowing you to easily traverse and display all subcategories under a specified category on the website front end, whether it is a direct subcategory or a multi-level nested subcategory, you can handle it with ease.Today, let's discuss how to implement this feature in Anqi CMS templates.

2025-11-09

How to embed a comment list on the page and control its pagination display?

In website operation, user interaction is the key to enhancing site activity and content value.AnQiCMS provides a set of intuitive and powerful features that help us easily embed comment functions in pages and flexibly control the display of comment lists, especially its pagination management, which is crucial for pages with a large number of user comments. ### Enable comment functionality to bring content to life Firstly, we need to ensure that the comment functionality is enabled on the backend so that users can post comments.Once the comment feature is activated

2025-11-09

How to enable Markdown rendering and correctly display mathematical formulas and flowcharts in AnQiCMS?

In AnQiCMS, if you want to make your content more expressive, especially when it comes to displaying complex mathematical formulas or clear flowcharts, it is a very effective solution to flexibly use the Markdown editor.The new version of AnQiCMS has provided good support for this.Next, we will explore together how to enable these features in AnQiCMS, making your website content come alive.

2025-11-09

How to use Tag tags to display related article lists on the page?

In website content operations, how to efficiently organize content, improve user experience, and optimize search engine rankings is a key focus for every operator.AnQiCMS as an enterprise-level content management system provides powerful and flexible functions to meet these needs, among which the Tag label function is an indispensable part.Tag label, simply put, is a keyword or thematic word, which can link scattered article content on a website according to common themes or focus points.Reasonably utilizing Tag tags can not only make it easier for users to discover content of interest

2025-11-09

How to configure and display the global contact information of the website, such as phone number, address, WeChat QR code?

In website operation, clearly and accurately displaying contact information is a key link in building user trust and improving service efficiency.Whether it is a phone number, address, email, or the popular WeChat QR code, AnQiCMS provides a flexible and convenient way to configure and manage these global information to ensure they can be presented efficiently on the website. ### Backend Configuration: Centralize your global contact information To centralize this information, you need to log in to the AnQiCMS admin interface. After logging into the backend, please navigate to the left menu bar of “**Backend Settings**”

2025-11-09

How does AnQiCMS handle uploaded images to optimize front-end loading speed and display quality (such as Webp, automatic compression)?

In today's fast-paced online world, website loading speed and content display quality directly affect user experience and search engine rankings.Images are an important part of a website's content, and their handling is crucial for website performance.AnQiCMS (AnQiCMS) fully understands this, and therefore provides a series of powerful and practical functions in terms of image upload and management, aimed at helping us easily optimize the front-end loading speed and improve the display quality of images.### Core Strategy: Convert to WebP format, improve loading efficiency The choice of image format has a significant impact on website performance

2025-11-09

How to batch regenerate thumbnails to adapt to the new frontend display size requirements?

The website's front-end interface has been completely refreshed, you may find that the old thumbnail images do not fit well in the new layout, either the size is not right or the display effect is not good.Don't worry, AnQiCMS (AnQiCMS) provides you with a convenient and efficient solution to help you batch regenerate thumbnails and easily adapt to the new front-end display size requirements.Why do you need to regenerate thumbnails?The visual presentation of a website is crucial for user experience.

2025-11-09