In website operation, we often encounter such needs: a particular product display page needs a unique layout to emphasize its features, or an important special topic page needs special design to attract users, or a single-page 'About Us' section wants to show a different brand character.Our company, AnQi CMS, provides a flexible way for us to customize exclusive display templates for this unique content, thus greatly enhancing the visual appeal and user experience of the website.

The template system of Anqi CMS has adopted the syntax of Django template engine, which is intuitive and efficient, providing great convenience for content creators and developers.It supports us to specify different template files based on content ID (such as a specific article, product) or category ID (such as a category of articles, product column), so 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. Highlight 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. Optimizing user experience:Targeting different types of content, providing the most suitable templates for reading and interaction, such as large image layouts for content primarily consisting of images, and clear layouts and code highlighting for technical documents.
  3. Strengthen brand imageIn some core pages, such as "About Us" and "Contact Us", customized templates can better integrate brand elements and deepen users' impression of the brand.
  4. Adapt marketing strategies: Coordinating with specific marketing activities, quickly switch or launch special page templates with marketing elements to improve operational efficiency.

The Anqi CMS makes it easy to name template files with a simple convention, making this process effortless.

Custom document (article/product) detail page template

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

Before specifying a template, you need to create this special template file first. Anq CMS stipulates that the custom template file 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 some article document you have is123and the name of its model table isarchive, you can create a template file namedarchive/detail-123.html. Or if you have a product ID of456The product, model table name isproduct, you can createproduct/detail-456.html.

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

Custom category (column) list page template

For a specific category (such as the list page under the "News UpdatesAutoCMS allows you to customize a dedicated list template for each category.

Similarly, you will 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, its model table name isarchive, you 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.

Create a template file first, log in to the Anqi CMS backend, go to the "Content Management" under the "Document Categorylist-10.html)。It is worth mentioning that there is also an option of “Apply to subcategories”. If you check it, all subcategories under this category will automatically inherit this custom template, saving the trouble of repeating the settings for each subcategory.

In these custom category list templates, you can usecategoryDetailtags to obtain detailed information about the category itself and combinearchiveListThe label is used to display the document list under the category, and to implement 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 of a single page are usually located in/template/page/The directory. The file naming format can bepage/{单页面ID}.html,or more flexibly, usingpage/{自定义URL别名}.html. For example, if you have a single-page ID of1,you can createpage/1.html. If your 'About Us' page is set to a custom URL alias in the background,about_usEnglishpage/about_us.html.

When editing a single page in the background, enter the name of the template file you created (such asabout_us.html),System will load the template you specified when accessing this page. Inside the template, you can use the tag to obtain all information such as the title, content, and images of a single page.pageDetail标签来获取单页面的标题、内容、图片等所有信息。

The storage of template files and basic structure

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

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

Practical skills for custom template

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

  • Apply conditional judgment flexibly:For some pages that only require minor adjustments, it is not necessary to create a new template file. You can use the generaldetail.htmlorlist.htmltemplate, and utilize `{% if