In daily website operation, we often encounter such situations: some articles are in-depth reports, some are event promotional pages, and some are corporate profiles or product details.Each has unique display requirements, and if they all follow the website's common template, it may seem monotonous and fail to fully exert the attractiveness of the content.AnQi CMS is an efficient and flexible content management system that fully considers this personalized demand, allowing us to set independent display template files for specific articles, categories, even single pages, making the content display more tailored and impactful.

Imagine you are in the middle of an important product launch and need a unique landing page to attract users;Or a deep industry analysis report, hoping to present it to the reader in a more professional format to enhance the authority of the content.At this time, it is particularly important to set up a dedicated template for this specific content.This can not only make your website content more differentiated and recognizable, but also bring significant improvement in user experience, brand image, and even 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.

Anqi CMS template mechanism overview

The template system of Anqi CMS is designed to be very flexible. It uses.htmlas the template file suffix, and stored in/templateIn the different theme folders under the directory. The system uses a syntax similar to the Django template engine, allowing you to easily get started with template development and modification.Whether it is adaptive, code adaptation, or PC + mobile independent site mode, AnQiCMS can provide perfect support.

In the template loading order, AnQi CMS has a clear priority: it will first check if the specific content has specified a custom template file. If specified, it will use this custom template; if not, it will follow the predefined rules (for example, try to match first){模型table}/{文档id}.htmlSuch automatic template naming, then fallback to the general template) for loading. This mechanism provides us with great convenience for fine-grained control of content display.

Core operation: specify an independent template for specific content

Set independent templates for articles, categories, or single pages, which mainly consists of two steps: first, prepare your custom template file, and then specify the file in the background for the corresponding content.

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/template/default/Create or upload your custom template file. Give the template file a clear, easy-to-identify name, such asspecial-promotion.htmlUsed for special promotion pages, orindustry-report.htmlUsed for industry reports.

When writing these custom templates, you can take advantage of the powerful template tag features of Anqicms to retrieve and display dynamic content. For example,{% archiveDetail %}Tags can help you get detailed information about the article,{% categoryDetail %}used to get category details,{% pageDetail %}it is used to get the content of a single page. At the same time, you can also use{% extends %}tags to inherit the common skeleton template of your website (such asbash.htmlThis way, you do not have to rewrite the header, footer, and other common parts from scratch, 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/Create a file namedmy_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 tell AnQi CMS which content should use this new template.This process is very intuitive, usually it can be completed on the content editing page.

  • Set an independent template for a specific article:

    • Enter the Anqi CMS background, navigate to "Content Management" -> "Document Management".}
    • Select the article you need to customize, click the 'Edit' button.
    • Find the collapsible area named 'Other Parameters' at the bottom of the document editing interface and expand it.
    • You will see a text box named "Document Template". Here, enter the path and name of the custom template file you just created, for examplearticle/my_custom_detail.htmlOr if your template file is directly placed in the theme root directory, you can fill it directlyspecial-promotion.html.
    • After saving the article, visit the front 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 you need to customize the template, click the 'Edit' button.
    • Below the category editing page, you can also find the 'Other Parameters' area and expand it.
    • Find the input box for 'Category Template' and enter the path and name of your custom template file, for examplecategory/product_list.html.
    • Here is another very useful option is whether to apply to subcategories.If you want all subcategories under this category to use this custom template, 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 page list of the category to see the changes in the template.
  • Set an independent template for a specific page:

    • Enter the Anqi CMS backend and navigate to 'Page Resources' -> 'Page Management'.
    • Select the single page template you need to customize (such as "About Us"), click the "Edit" button.
    • Find the "Single Page Template" input box at the bottom of the single page editing interface.
    • Enter the path and name of your custom template file, for examplepage/about_us_unique.html.
    • After saving a single page, visit the page, and it will be displayed with a brand new template style.

Tips and注意事项

  • Accuracy of the pathEnsure that the path entered for the template file in the background is accurate. This path is relative to the root directory of the currently active theme template (i.e./template/您的主题文件夹/In this context.
  • Test in time.: After you set or modify a custom template, you should immediately visit the front page for testing to ensure that everything displays normally and that all dynamic content can be loaded correctly.
  • Unified EncodingPlease ensure that all template files use UTF-8 encoding to avoid garbled characters.
  • Make full use of tags: 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 and make good use of these tags, which can make your template more powerful and dynamic.
  • Mobile AdaptationIf your website uses a PC + mobile independent site mode, don't forget tomobile/create a corresponding mobile version of your custom template in the directory to ensure that there is also a good one on the mobile end