As an experienced website operations 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 provides a solid foundation with its lightweight and high-performance Go language, while its powerful template customization capabilities grant infinite possibilities to content operators.
Today, let's delve into how to accurately find and edit the template folder currently in use on AnQiCMS.This may sound a bit technical, but don't worry, I will guide you step by step in the most straightforward way possible.
Template, the 'soul' and 'facade' of the website
Before starting specific operations, let's first understand the role of the template in AnQiCMS and on all websites.Templates are not just the 'skin' of a website; they are the carrier of the brand image, the cornerstone of user experience, and an important link in search engine optimization.By fine-tuning the template, we can ensure that the visual style of the website is highly consistent with the brand, 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 learn and modify relatively easily, 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 directory/templateThis directory may contain 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:
/templateFirstly, you need to find the installation path of AnQiCMS. In this path, you will see a file namedtemplateThe folder.All templates available on your website, including those built-in and those you may upload or develop later, will be stored in this directory, with each template in an independent folder.Identify the activation template:
config.jsonofstatus: 1Enter/templateAfter the folder, you will see some subfolders, such asdefault/mobile[en] Wait, or a custom template name you have set. To determine which template is currently in use, you need to enter each subfolder, search for, and open the file namedconfig.json[en] of the file.in this
config.jsonIn the document, 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 isconfig.jsonin the filestatusField is set to1used, it means that the template is the active template currently being used by the site. Other templates'statusvalues are usually0.
Therefore, by examining each template folder under,
config.jsonyou can quickly find the template folder currently in use on the site. For example, if,/template/my_custom_theme/config.jsonin"status": 1so thatmy_custom_themeis the folder you are looking for.
Two main ways to edit template files
Found the template folder, next is the editing. AnQiCMS provides two main methods to modify template files to meet the needs and habits of different users.
Method one: Directly modify through the file system (recommended for users with server operation experience)
This is the most direct and the most common way.This approach 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:Log in to your server using an FTP/SFTP client (such as FileZilla) or 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 includes common code referenced on each page, such as headers and footers. - Code snippet:
partial/The catalog contains reusable code snippets such as sidebars and breadcrumbs. - Core pages:Like the home page
index/index.html, article detail page){模型table}/detail.html, list page{模型table}/list.htmlare all the files you may need to pay close attention to. - Mobile template:If your site has enabled the independent template mode for mobile devices, you will also see a directory in the current template folder.
mobile/This directory contains the corresponding mobile template files. - Grammar Points:AnQiCMS uses a template engine syntax similar to Django. Variables are enclosed in double curly braces
{{变量名称}}to output, while logical operations such as conditional judgment, loop control, etc., are used{% 标签 %}and{% end标签 %}Occur in pairs. When editing text, please ensure that the template file is uniformly adopted.UTF-8 encoding.Otherwise, it may cause the page to display garbled characters.
- 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:Be sure tocomplete backupTransfer to a local or secure location. Incorrect modifications may cause the website to display abnormally or become inaccessible.
Method two: Edit the template online through the AnQiCMS backend (suitable for quick adjustments or users not familiar with the server)
Starting from version 2.1.0 of AnQiCMS, the system has added the feature of editing background templates, which provides great convenience for content operators.
- Log in to the AnQiCMS admin panel:Log in to the AnQiCMS management interface using your admin account.
- Navigate to template design:Find and click on it in the left navigation bar.
模板设计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 backend editor usually provides features such as syntax highlighting to help you edit code more efficiently.
- Save changes:After editing, click the save button. The system will automatically update the template file on the server.
Advantages:This method does not require leaving the browser, with convenient operations, especially suitable for some small-scale style or text adjustments.Caution:Although 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 to avoid affecting the stability of the online website.
[en] Practical Tips
- Develop a good habit of backup:Emphasizing a hundred times is not enough. Please make a backup before making any template modifications! This will allow you to quickly recover in case of any unexpected events.
- Understanding template tags:AnQiCMS provides a rich set of template tags (such as
system/contact/archiveListThey are the bridge between you and the website data. Spending time reading the official documentation about template tags (such as the descriptions in the documentation) will greatly enhance your template customization ability.design-tag.md),will greatly enhance your template customization ability. - Start modifying from the copy:If you plan to make extensive customization of the template, consider making a copy of the currently active template folder, and then
config.jsonofstatusset0,packageModify 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 handy 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, devices (PC, mobile, tablet) to ensure that the display and functionality are normal.
Having mastered the location and editing skills of the AnQiCMS template folder, you will possess the powerful ability to control the appearance and functionality of the website.Hope this guide can help you better utilize AnQiCMS and create a unique, high-performance website!
Common Questions (FAQ)
Q1: What should I do if the front-end website content does not update immediately after modifying the template file?A1: AnQiCMS usually caches page content to improve access speed.When 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 a new folder in/templatedirectory (for examplemy_new_theme), and create a file in this folder.config.jsonFile, as per the documentdesign-director.mdfill in the template information in the format (e.g., "name": "My new template")}]