How to find and edit the template folder being used by the current site in AnQiCMS?
As an experienced website operation expert, I know that mastering the positioning and editing methods of templates in a flexible and efficient content management system like AnQiCMS is a key step in achieving website personalization, improving user experience, and optimizing SEO.AnQiCMS with its lightweight and high-performance Go language provides us with a solid foundation, and its powerful template customization capabilities give content operators unlimited possibilities.
Today, let's delve into how to accurately find and edit the template folder used by the current site in AnQiCMS.This might sound a bit technical, but don't worry, I will guide you step by step in the most easily understandable way.
Template, the soul and facade of the website
Before starting the specific operation, let's first understand the role of the template in AnQiCMS and all websites.Templates are not just the 'skin' of a website; they are also the carrier of the brand image, the cornerstone of user experience, and an important part of search engine optimization.By fine-tuning the template, we can ensure that the visual style of the website is highly consistent with the brand tone, provide smooth user interaction, and offer a friendly content structure for search engines, thereby effectively enhancing the competitiveness of the website.The Django template engine syntax provided by AnQiCMS allows even non-professional developers to relatively easily learn and modify, achieving personalized content display.
Locate the template folder of the current site
AnQiCMS has a clear logic in managing templates. All template files are uniformly stored in the root directory under its installation path/templateIn this directory, there may be multiple template folders, each representing a set of independent templates. So, how do we know which one is currently being used by the site?
The answer is in a key file inside each template folder:config.json.
Global template directory:
/templateFirst, you need to find the installation path of AnQiCMS. In this path, you will see a file namedtemplateThe folder. All the templates available on your site, including the ones built-in and those you may upload or develop later, will be stored in this directory, with each template in its own independent folder.Identify the activation template:
config.jsonofstatus: 1Enter/templateAfter the folder, you will see some subfolders, such asdefault/mobilewait, or you can customize the template name. To determine which template is currently being used, you need to enter each subfolder, find and open the file namedconfig.json.in this
config.jsonIn the file, there are two fields that are particularly important:"package": "模板文件夹名称"This field defines the name of the template folder, which is usually consistent with the name of the folder it is in."status": 1This is the key! When a template folder containsconfig.jsonin the filestatusthe field is set to1it means that the template is the currently active template being used on the site. Other templates'statusvalues are usually0.
Therefore, by viewing the contents of each template folder
config.jsonyou can quickly find the template folder currently in use on the site. For example, if/template/my_custom_theme/config.jsonin"status": 1thenmy_custom_themeit is the folder you are looking for.
Two main ways to edit template files
Found the template folder, the next step is to edit. AnQiCMS provides two main methods to modify template files to meet the needs and habits of different users.
Method 1: Modify directly through the file system (recommended for users with server operation experience)
This is the most direct and common way. It is very efficient for users with experience in operating FTP/SFTP or server file managers (such as Baota panel, 1Panel, etc.)
- Connect to the server:Use an FTP/SFTP client (such as FileZilla) or log in to your server through your server management panel (such as Baota Panel, 1Panel).
- Navigate to the template directory:Find your AnQiCMS installation path and enter it
/template/您识别出的当前模板文件夹. - Start editing:
- Public section:
bash.htmlIt usually contains header, footer, and other common code referenced by each page. - code snippet:
partial/The directory contains reusable code snippets such as sidebars, breadcrumbs, etc. - Core pages:Like the homepage
index/index.html, article detail page{模型table}/detail.html, list page{模型table}/list.htmlThese, are all the files you may need to pay attention to. - Mobile Template:If your site has enabled the independent template mode for mobile devices, then you will also see one in the current template folder.
mobile/Subdirectory, containing corresponding mobile template files. - Syntax points:AnQiCMS uses a template engine syntax similar to Django. Variables are enclosed in double curly braces.
{{变量名称}}Output, while conditional judgment, loop control, and other logic are used{% 标签 %}and{% end标签 %}Appear in pairs. When performing text editing, be sure to ensure that the template file is uniformly adoptedUTF-8 encodingOtherwise, it may cause page garbling.
- Public section:
- Save and Upload:After modification, save the file and upload it to the server via FTP/SFTP or other methods to overwrite the original file.
Important reminder:Before modifying any template files, please make sure toa full backupto the local or another secure location. Incorrect modifications may cause the website to display errors or become inaccessible.
Method two: Through AnQiCMS background online template editing (suitable for quick adjustments or users unfamiliar with the server)
Since the AnQiCMS v2.1.0 version, the system has added the function of editing background templates, which provides great convenience for content operators.
- Log in to the AnQiCMS backend:Log in to the AnQiCMS management interface using your admin account.
- Navigate to template design:Find and click in the left navigation bar
模板设计and then select网站模板管理. - Select and edit:Here, you will see the list of templates you are currently using.Click the edit button next to the corresponding template to directly modify the template file in the browser.The background editor usually provides features such as syntax highlighting and other auxiliary functions to help you edit code more efficiently.
- Save changes:After modification, click the save button. The system will automatically update the template file on the server.
Advantage:This method does not require leaving the browser, it is convenient, especially suitable for making some small-scale style or text adjustments.Note:Even though the background editing feature is very convenient, it is still strongly recommended to back up locally and verify the effect of the modifications in the test environment before making large-scale changes to the core template files, in order to avoid affecting the stability of the online website.
**Practice and Suggestions
- Develop the habit of backing up:Emphasizing a hundred times is not too much, please back up before each template modification! This will allow you to recover quickly in case of any unexpected events.
- Understand template tags:AnQiCMS provides a rich set of template tags (such as
system/contact/archiveListThey are the bridge between you and the website data. Take the time to read the official documentation about template tags (such as those in the documentation of thedesign-tag.md), which will greatly enhance your ability to customize templates. - Start modifying from the copy:If you plan to make extensive customizations to the template, consider copying the current active template folder and its
config.jsonofstatusis set to0,packageChange to a new name. Activate the new template in the test environment and make modifications on the new template. This can prevent direct damage to the online environment. - Use the development tools: Browser developer tools (F12) are your good helper for debugging front-end styles and finding elements.
- Test, test, and test again: Any modification, no matter how small, should be tested on different browsers and devices (PC, mobile, tablet) to ensure that the display and functionality are normal.
You have mastered the skills of locating and editing the AnQiCMS template folder, and you have the powerful ability to control the appearance and function of the website.Hope this guide can help you better utilize AnQiCMS to create a unique, high-efficiency website!
Frequently Asked Questions (FAQ)
Q1: How do I update the front-end website content immediately after modifying the template file?A1: AnQiCMS usually caches page content to improve access speed.After you modify the template file, you may need to clear the system cache to see the latest changes.You can log in to the AnQiCMS backend, find and click the "Update Cache" feature in the left navigation bar, and perform the clear operation.If it still does not work, try clearing the browser cache or accessing in incognito mode.
Q2: Can I create my own new template? What should I pay attention to?A2: Of course! AnQiCMS highly supports custom templates. You just need to create/templatea new folder under the directory (for examplemy_new_theme), and create aconfig.jsonFile, fill in the template information according to the documentdesign-director.mdin the format (for example, "name": "My new template"