In the operation of daily websites, we often encounter such situations: some articles are in-depth reports, some are promotional pages for events, and some are company profiles or product details.They each have unique display requirements. If they all continue to use the website's general template, it might seem monotonous and fail to fully leverage the appeal of the content.AnQi CMS, as an efficient and flexible content management system, fully considers this personalized demand, allowing us to set independent display template files for specific articles, categories, or even single pages, making content display more tailored and impactful.
Imagine you are launching a significant product and need a unique landing page to attract users; or a deep industry analysis report that you want to present to readers in a more professional format to enhance the authority of the content.It is particularly important to set a dedicated template for these specific contents at this time.This not only makes your website content more differentiated and recognizable, but also significantly improves user experience, brand image, and search engine optimization (SEO).By customizing templates, we can better control the visual presentation of content, guide users to focus on key information, thereby improving conversion rates and user stickiness.
Overview of the template mechanism of Anqi CMS
The template system of AnQi CMS is designed to be very flexible. It uses.htmlas the suffix for template files and stores them centrally./templateIn different folders under the catalog.The system uses syntax similar to the Django template engine, allowing you to easily start developing and modifying templates.Whether it's adaptive, code adaptation, or the PC + mobile independent site model, AnQiCMS can provide comprehensive support.
On the template loading order, Anqi CMS has a clear priority: it will first check if a specific content has specified a custom template file. If specified, it will use this custom template; if not, it will follow the preset rules (for example, try to match first).{模型table}/{文档id}.htmlSuch automatic template naming, then fallback to the general template for loading. This mechanism provides great convenience for our fine-grained control of content display.
Core Operation: Specify an independent template for specific content
Set independent templates for articles, categories, or single pages, mainly divided into two steps: first, prepare your custom template file, and then specify the file to the corresponding content in the background.
1. Prepare your custom template file
First, you need to be in the current website template directory (for example, if you are using the default template, it is usually located in)/template/default/Create or upload your custom template file. Give the template a clear, identifiable name, such asspecial-promotion.htmlfor special promotion pages, orindustry-report.htmlfor industry reports.
When writing these custom templates, you can take advantage of the powerful template tag features of the Anqi CMS to retrieve and display dynamic content. For example, {% archiveDetail %}Tags can help you get detailed information about articles,{% categoryDetail %}used to obtain the category details,{% pageDetail %}which is used to get the content of a single page. At the same time, you can also use tags to inherit the common skeleton template of your website (for example,{% extends %}tags to inherit the common skeleton template of your website (for example,bash.htmlThis way, you do not need to rewrite the header and footer, etc., just focus on the unique design of the content area, which greatly improves development efficiency.
For example, if you want the article detail page to have a unique layout, you can/template/default/article/in the directorymy_custom_detail.htmlfile, and use{% extends 'bash.html' %}to inherit the basic layout, then use{% block content %}to rewrite the display of the content area.
2. Specify the template in the background
When your custom template file is ready, the next step is to inform the Aiqi CMS which content should use this new template.This process is very intuitive, usually completed on the content editing page.
Set an independent template for a specific article:
- Go to the “Content Management” -> “Document Management” in the AnQi CMS background.
- Select the article you need to customize, click the "Edit" button.
- At the bottom of the document editing interface, find the collapsed area labeled "Other Parameters" and expand it.
- You will see an input box named 'Document Template'. Here, enter the path and name of the custom template file you just created, for example,
article/my_custom_detail.htmlor if your template file is directly placed in the theme root directory, you can fill in directlyspecial-promotion.html. - After saving the article, visit the front-end page of the article, and you will see that it has applied the custom template you specified.
Set an independent template for a specific category:
- Enter the AnQi CMS backend, navigate to "Content Management" -> "Document Category".
- Select the category of template you need to customize and click the "Edit" button.
- At the bottom of the category editing page, find the 'Other Parameters' section and expand it.
- Find the 'Category Template' input box and enter the path and name of your custom template file, for example.
category/product_list.html. - Here is a very useful option, 'Whether to apply to subcategories'.If you want all subcategories under this category to use this custom template as well, just check this option.Otherwise, only the current category will be applied, and child categories will continue to use their own or parent templates.
- After saving the category, visit the front desk list page of the category to see the changes in the template.
Set an independent template for a specific single page:
- Enter the Anqi CMS backend, navigate to "Page Resources" -> "Page Management".
- Select the single page (such as "About Us
- At the bottom of the single page editing interface, find the input box for "Single Page Template".
- Enter the path and name of your custom template file, for example
page/about_us_unique.html. - After saving the single page, visit the page, and it will be presented with a new template style.
Tips and注意事项
- Accuracy of the pathPlease make sure the template file path is entered accurately in the background. This path is relative to the root directory of the currently enabled theme template (i.e.,
/template/您的主题文件夹/In terms of. If the template file does not exist or the path is incorrect, the page may not display normally and may even report an error. - Test promptlyWhen you set or modify a custom template, you should immediately access the front page for testing to ensure that everything displays correctly and that all dynamic content loads properly.
- Unified CodingPlease ensure that all template files use UTF-8 encoding to avoid garbled character issues.
- Make full use of tagsThe AnQi CMS provides a rich set of template tags and filters, which are powerful tools for you to retrieve and process data in custom templates.Familiarize yourself with and make good use of these tags, which will make your template more powerful and dynamic.
- Responsive design for mobile devicesIf your website uses a PC+mobile independent site mode, don't forget to
mobile/create a corresponding mobile version of your custom template under the directory to ensure that there is also a good