As a senior CMS website operation person in a security enterprise, I know that the flexibility of content display is crucial for attracting and retaining users.AnQi CMS provides powerful template customization capabilities, allowing us to specify independent template files for different pages, thereby achieving personalized content layout and design.This is particularly important for creating unique single-page applications, such as 'About Us', 'Contact Information', or specific event landing pages.

Understanding the template mechanism of Anqi CMS

All template files in Anqi CMS are stored in the same place./templateUnder the directory, and organize with theme folders. Each theme can use folder organization mode or flattened file organization mode.For a single-page, the default template file is usuallypage/detail.htmlThis means that when a single page is created without specifying a particular template, the system will automatically applypage/detail.htmlTo render its content. However, to meet more advanced customization needs, Anqi CMS allows us to specify a completely independent template file for any single page.

Why do we need an independent single-page template

In actual operation, many scenarios require a single page to have a unique design different from the general layout. For example:

  • About Us pageIt may be necessary to display rich content such as team member introductions, timelines of development history, etc., and specific layouts are needed to enhance the brand image.
  • “Contact Us” pageIn addition to basic contact information, it may also be necessary to integrate maps, online forms, or multi-channel customer service portals, which requires a customized template to present efficiently.
  • Landing page for marketing activitiesIt usually requires highly customized visual design and content layout to maximize conversion rates. An independent template can ensure that these pages are not limited by the universal layout.
  • Download center or information display pageMay require specific file lists, search or filter functions, independent templates can provide a more professional interactive experience.

By specifying independent templates for these single-page applications, we can free ourselves from the constraints of the universal layout, allowing for more free design of page structure, style, and functionality, thereby better serving content goals and user experience.

Create your custom single page template file

To specify an independent template file for a single page, you first need to create this file.

You need to create a special directory for storing custom single-page templates within the current theme directory, for example/template/您的主题名称/page/Of course, you can also directly place the template file in the root directory of the theme, but in order to maintain good file organization and management, it is recommended to create it inpage/directory.

The naming of template files should be descriptive and easy to identify, and must be used.htmlAs a file extension. For example, if you want to create a dedicated template for the "About Us" page, you can name itabout-us.html. If you have a special download page, you can name itdownload-page.html.

In this new one.htmlIn the file, you can write the unique HTML structure and content of this single page.You can fully utilize the various tags and filters provided by the Anqi CMS template engine, introduce common components such as headers and footers, and define content layout and style according to the specific needs of the page.

Apply custom template in Anqi CMS background

After creating a custom template file, the next step is to apply it to a specific single page in the Anq CMS backend management interface.

Please log in to your Anqi CMS backend and navigate toPage Resourcesthe section, then clickPage Management. Here, you can choose to edit an existing single page or create a new single page.

In the editing or creation interface of a single page, scroll down to findSingle page templatethis setting item. This field allows you to enter the name of the template file used to render the current single page.

Here, you need to enter the name of the custom template file you just created. For example, if your template file is located/template/您的主题名称/page/about-us.html, then you just need to fill in the input box.page/about-us.html. If you place the template file directly in the theme root directory, for example/template/您的主题名称/download.html, then fill indownload.htmlJust do it.

After filling out, please make sure to save all changes on the single page. After the save is successful, when the user accesses this single page, the system will no longer use the default.page/detail.htmlInstead, it will load and render the one you specified.page/about-us.html(or other custom template) to display page content.

Key points to note

  • Existence of template file:Ensure that the template file name you have filled in the background is accurate, and that the file indeed exists in the specified path of your current theme.If the file does not exist or the path is incorrect, accessing the single page may cause errors or display a blank page.
  • Relative path:The value entered in the 'Single Page Template' field should be the path and filename relative to the root directory of the current theme.
  • Template syntax:The custom template file should follow the Django template engine syntax supported by Anqi CMS to ensure that content and logic can be correctly parsed.
  • Test verification:After completing the setup, be sure to visit this single page, check if the custom template has been successfully applied, and whether the page content, layout, and functionality are all displayed and working as expected.

By following these steps, you can flexibly specify independent template files for each single page in AnQi CMS, thereby achieving richer and more attractive website content display.

Frequently Asked Questions

Q1: What will happen if the custom template file I specified does not exist?A1: If the custom template file specified for the single page does not exist or the path is incorrect, the system will not be able to find the corresponding template file to render when the user accesses the single page.This usually leads to page display errors, blank pages, or system errors.Therefore, after setting up a custom template, be sure to check that the template file exists and that the path is accurate.

Q2: Can I use the template tags and filters of AnQi CMS like other templates in a custom single-page template?A2: Of course you can. Custom single page templates are just like other template files in Anqi CMS, fully supporting the use of various built-in template tags (such assystem/archiveList/pageDetailand) and filters (such assafe/truncatechars/stampToDateThis allows you to flexibly call system data and control content formatting in custom templates, achieving rich functions and interactions.

Q3: After specifying an independent template for a single page, will it affect other single pages on my website?A3: No. Specifying an independent template file for a single page results in a local effect, affecting only the specific single page you set.The single page without a specified independent template will continue to use the system default'spage/detail.htmlTemplates, or using the specific templates set in their respective backend settings, do not affect each other.