How to set an independent display template for a specific page or content block in AnQi CMS?

Calendar 81

In the daily operation of Anqi CMS, we often encounter the need: certain pages or content need to break away from the unified style of the website and present in a unique way.This could be to highlight an important product, create a dedicated landing page for a special topic event, or simply make the "About Us" page more brand-specific.Fortunately, Anqi CMS is renowned for its high customizability, providing us with a flexible way to set independent display templates for specific content, thus realizing this personalized display requirement.

The flexible content model and template management mechanism of Anqi CMS is the key to achieving our goal.It allows us not only to fill content, but also to deeply control the way content is presented, which is of great benefit for improving user experience, optimizing SEO, and even achieving differentiation in content marketing.

Why do you need an independent display template?

Most of the content on the website usually follows a set of unified design standards, which helps maintain brand consistency.However, there are always some 'special cases' that need special treatment.Imagine that your website has a "Download Center" page, which may need a simple layout to highlight the download buttons and descriptions; or a product promotion page, which may need an eye-catching full-screen slideshow and a form to collect potential customer information.If all these pages follow the general template, it will be difficult to achieve **the marketing effect and user conversion rate.Setting them up with an independent display template means you can tailor the visual experience and functional layout for these key contents, making them stand out among numerous content and better serve specific business objectives.

The home of template files: the template directory structure of AnQi CMS

In AnQi CMS, all template files are stored centrally under the root directory of the website/templateIn the folder. Each installed template theme will have an independent folder in this directory, for exampledefault. Inside this theme folder, you will find organized HTML files that determine the layout and style of the website's front-end pages. For example, the article detail page usually has aarticle/detail.html, there may be in the category list page,article/list.html, while the single page might be,page/detail.html. These HTML files use a syntax similar to the Django template engine (using,{{变量}}to retrieve data,{% 标签 %}Control logic to render dynamic content.

Static resources, such as CSS, JavaScript, and images, are usually stored in./public/static/Under the directory, separated from the template file, convenient for management and CDN acceleration.

How to create your exclusive template file?

The essence of creating a custom display template is to make one in the folder of the template theme you are currently using, which conforms to the Anqi CMS template rules..htmlFile. Anqi CMS provides some default template file naming conventions, such as searching for the article detail pagedetail.html, searching for the category list pagelist.html. But more importantly, it allows us to set the names for these files.Custom namesto meet the needs of specific pages.

For example, if you want to set a unique template for a specific article named "Download Center", you cantemplate/{你的模板主题名}/article/Create a file nameddownload.htmlThe file. Similarly, if your "About Us" page needs special styling, you can create atemplate/{你的模板主题名}/page/about.htmlfile. The key is, this custom.htmlThe file will be specified as the display template for the content in the subsequent backend settings.

In these custom template files, you can use various template tags provided by Anqicms as you would with other standard templates (such as{% archiveDetail %}used to obtain article details,{% pageDetail %}Used to obtain detailed information of a single page, etc.) to call the required data, and combine HTML, CSS, and JavaScript for layout and beautification.

Assign independent templates for different types of content

AnQi CMS provides an intuitive backend interface for assigning these custom templates for different types of content:

  1. Set an independent template for a specific article (document):Go to the "Content ManagementIn the document editing interface, scroll down to find a field named 'Document Template'.download.htmlAfter saving the document, the article will automatically load and use the template you specified when accessed on the front end:download.htmlto render the template.

  2. Set an independent template for a specific category:For document classification, the process is similar.Under 'Content Management', go to the 'Document Classification' page, and edit the category you want to set (for example, a subcategory under 'News Center').In the category editing page, you will see a 'category template' field in the 'other parameters' area.article/news_special_list.html. It is also worth mentioning that there is also an option for 'whether to apply to subcategories'.If you check this option, all subcategories under the current category will automatically inherit and use this custom template, which is very convenient when it comes to managing the display of certain types of sub-content uniformly.

  3. Set an independent template for a specific page:The single-page settings are equally intuitive.In the 'Page Resources' under 'Page Management', edit your single page, such as 'About Us'.page/about.htmlAfter saving, this page will display the dedicated template.

Successfully applied and注意事项

It should be noted that the custom template file you specify must truly exist within the template theme package you are using.If the template file does not exist, the corresponding page may encounter errors when accessed or may not display normally.Therefore, be sure to confirm that the template file has been uploaded to the correct location before specifying the template name in the background.

Also, if you want your website to have a unique display effect on both PC and mobile devices, then don't forget to create a custom template in the PC template directory and also within the template theme.mobileCreate the corresponding mobile template under the directory and use the same naming convention. Anqi CMS will automatically match the corresponding template based on the visited device.

Through these flexible custom template features, Anqi CMS is not just a content publishing tool, but also a powerful platform that can help you achieve diverse content presentation.It fills every corner of the website with personality and vitality, helping you to more effectively reach your target users and improve the overall operation of the website.


Frequently Asked Questions (FAQ)

1. What is the difference between custom template and content model fields?

The content model field defines the structured data of the content, such as the specific information of the article's 'author', 'source', etc., which is the 'skeleton' of the content.And custom templates determine how the 'skeleton' of these contents is dressed up in style on the front end, which is the 'skin' of the content.The template is responsible for layout, typesetting, and visual presentation, while the content model fields provide the data required by the template.Both are complementary relationships.

2. If I specify a custom template for a page but the template file does not exist, how will the page display?

If the specified custom template file does not exist, Anqi CMS will usually try to backtrack to the default general template for rendering (for example, article details will try to usearticle/detail.html, single page will trypage/detail.html)。However, this is not absolute, and under certain configurations, it may also directly cause the page to be inaccessible or display errors.Therefore, it is strongly recommended to access the front-end page immediately after setting up a custom template in the background, to ensure that the template file has been uploaded and activated correctly.

3. Can I reference other template fragments in a custom template?

Of course. The Anqi CMS template engine supports{% include "partial/header.html" %}Such a label, you can reference any code snippet of the website's public header, footer, sidebar, etc. in a custom template, and even reference other custom macro functions ({% macro %}This greatly enhances the reusability and maintenance efficiency of the template, allowing you to maintain code neat and structured while customizing individually.

Related articles

How to optimize the URL structure of Anqi CMS to improve search engine results?

In the world of digital marketing, a website's URL is not just a string of addresses; it is also the key for users and search engines to understand the content of the web page.A well-optimized URL structure not only enhances user experience but also significantly improves the website's crawling and ranking performance by search engines.For those who operate websites using AnQi CMS, using the powerful functions provided by the system to optimize the URL structure is an important step to improve the display effect of search engine results.Why is optimizing URL structure so important?

2025-11-08

How can AnQi CMS be configured and display multilingual content to expand the international market?

Expand the international market, allowing your content to reach global users is an important part of many enterprises' digital strategies.AnQiCMS (AnQiCMS) is well aware of this need and therefore built-in strong multilingual support and multi-site management capabilities from the very beginning, helping users efficiently configure and display multilingual content. ### Embarking on the journey of internationalization: The cornerstone of multilingual support AnQi CMS is committed to providing small and medium-sized enterprises and content operation teams with an efficient and flexible content management platform.

2025-11-08

How to customize the front-end content display layout of Anqi CMS website?

AnQiCMS provides highly flexible frontend content display layout customization capabilities, allowing websites to present unique visual effects and information structures according to specific needs.This is not only about the appearance of the website, but also about how to deliver content efficiently and accurately to visitors.By understanding the template mechanism and various functions of AnQiCMS, users can easily achieve fine-grained control from the overall theme style to the display of single content.

2025-11-08

How does AnQiCMS's `filter` tag combine multiple filters to process content in a chain?

AnQiCMS provides flexible and powerful content management capabilities, among which the template engine is the core of our daily operations and content display.When processing website content, we often encounter situations where we need to perform multi-step transformations to achieve the final display effect.For example, a long article summary may need to be truncated first, then ensure all letters are lowercase, and finally calculate the length of the processed text.If each time is handled manually through complex code logic, it is not only inefficient but also makes the template difficult to maintain.

2025-11-08

How to ensure that the AnQi CMS website displays content normally on PC, mobile, or adaptive mode?

When building and operating a website, the display effect of content on different devices is crucial to the user experience.AnQiCMS provides a variety of mechanisms and rich features to help users easily cope with the challenges of content display on PC, mobile, and various adaptive scenarios.Understanding and appropriately utilizing these features can effectively ensure that your website content is presented normally and beautifully on any screen.--- ## One, understand the responsive and adaptation mechanism of AnQiCMS AnQiCMS provides flexible options in website modes

2025-11-09

How to extract and display the thumbnail and cover image of the document content in Anqi CMS?

In AnQi CMS, managing and displaying document content thumbnails and cover images is an important aspect for enhancing the visual effects of a website, optimizing user experience, and improving search engine friendliness.AnQiCMS provides a flexible mechanism to handle these image resources, whether they are automatically extracted from the content or manually uploaded and specified, they can be managed in detail in the background and called through simple template tags on the front end.

2025-11-09

How to use the recommended attributes of Anqi CMS (such as headlines, sliders) to control the display of homepage content?

When building and maintaining a website, the homepage is undoubtedly the first stop for users to visit, and its way of displaying content directly affects user experience and information communication efficiency.A meticulously planned and flexible homepage layout that can effectively attract visitors, guide traffic, and highlight the core value of the website.AnQiCMS provides a series of powerful content recommendation features, allowing you to easily control the dynamic display of homepage content and meet various operational needs.Flexible use of AnQi CMS recommended attributes AnQi CMS in content management

2025-11-09

How does the custom content model of AnQi CMS affect the display of front-end data fields?

In website content management, flexibility is the key to improving efficiency and user experience.AnQiCMS (AnQiCMS) performs well in this aspect, with its custom content model feature being particularly powerful.It not only makes content management more organized, but also directly affects the way website front-end data is displayed, making it easy for the website to adapt to various content structures and business needs. ### Understanding Custom Content Model One of the core strengths of Anqi CMS lies in its "flexible content model".

2025-11-09