AnQi CMS with its powerful flexibility and ease of use has become a helpful assistant for many content operators.Especially in terms of content display, it provides us with rich customization space.For web pages that require unique layouts or specific functions, such as "About Us", "Contact Us", or a special event landing page, we often hope that they can have a completely different visual style from ordinary articles or list pages.A safe CMS provides a very convenient way, allowing us to set exclusive custom templates for these single-page websites, so that every corner of the website can meet our personalized needs.Today, let's take a detailed look at how to implement custom template settings and display on a single page in Anqi CMS.
1. Understand the single page and template mechanism of Anqi CMS
Firstly, we need to have a clear understanding of the 'single page' in Anqi CMS.As the name implies, a single-page refers to pages that are independent, not dependent on categories or specific content models, and are usually presented as a single piece of content.They are commonly used to display company profiles, service introductions, privacy policies, or as specific marketing activity pages.In Anqi CMS, these pages are created and edited through the "Page Resources" module under "Page Management."}
The template mechanism follows. Anqi CMS adopts a template engine syntax similar to Django, making our template creation and maintenance very intuitive. All template files are written with.htmlWith suffix, and stored uniformly in the root directory of the site/templatein the folder. To facilitate management, each template theme will have its own independent directory, such asdefault.
For a single-page, the system itself provides some default template rules. For example,page/detail.htmlIt is usually a general single-page detail template. Further, you can also create a single-page for a specific ID.page/detail-{单页ID}.htmlThis is a template. But the strength of Anqi CMS lies in its ability to allow us to define template filenames more freely.This means you are not limited to system-generated IDs, you can completely use page aliases or any meaningful names, such aspage/about-us.htmlCreate a dedicated template to achieve highly personalized display.
Second, set a custom template for a single page in the background.
The process of setting a custom template for a single page is very direct, mainly completed in the Anqi CMS backend management interface.
- Enter Page Management:Log in to the Anqi CMS backend, find the "Page Resources" module under the left-hand navigation bar.Here, you can choose to create a new single page or edit an existing one.
- Locate the field “Single Page Template”:After entering the single-page editing interface, you will see a series of fields for filling in page information, one of which is an option called "Single Page Template".This field is the key to specifying the custom template file.
- Enter a custom template filename:In the 'Single Page Template' field, you need to enter the name of the template file you have prepared for this single page. For example, if you want to design a very special layout for the 'About Us' page, you can prepare a file named in the template directory.
about-us.htmlThe file, so here you just fill inabout-us.html. The system will search for and apply the corresponding template in the template theme folder you are currently using according to the filename you enter.
It should be emphasized here that the filename you enter must be exactly the same as the template file name you create on the front-end, including the suffix (.html) and case. If the system cannot find the corresponding template file, the single page may display an error (such as a blank page) or revert to a default display method, which will affect the user experience.
Build the front-end custom template file
The template file name has been set up on the backend, and the next step is to create and write the custom template file.
- Determine the location of the template file:First, you need to enter the root directory of your Anqicms website, find
/templatefolder, then enter the theme directory you are currently using (for exampledefault)。To maintain good file organization and management, it is usually recommended to store the custom template files for a single page in the theme directory.page/In the subdirectory. Therefore, according to the settings of the background, you may need to create something similar/template/default/page/about-us.htmlsuch a file. - Write the template content:Open the one you created
.htmlFile, you can start writing your page layout and content. The Anqi CMS template engine supports rich syntax, allowing you