Where should the AnQiCMS template files be stored, and what file extensions are supported?
AnQiCMS is designed to be very clear and flexible in template file management, aiming to allow users to customize the appearance and functionality of the website efficiently.If you are using AnQiCMS to build or maintain a website, understanding the location of template files and supported suffixes is the foundation for frontend development and customization.
The core home of template files:/templateTable of contents
All AnQiCMS template files are stored in a core directory, which is under the root directory of your website/templateFolder. This directory is the 'home' of all your theme packages. In/templateUnder the directory, each independent theme package will have its own subdirectory, such asdefault/my_custom_themeetc.
In each theme package subdirectory, there is usually oneconfig.jsonThe file. This configuration file records the theme name, version, author, description and other basic information, as well as the template types it supports (such as adaptive, code adaptation, or PC + mobile independent station mode).Through this structure, AnQiCMS can identify and manage different theme packages.
The template file suffix is unified and clear.html
The template file suffix of AnQiCMS is unified.htmlThis means that whether you are creating a homepage template, an article detail page template, a category list page template, or any other page, they should be designed to.html.
This choice is highly consistent with the Django template engine syntax supported by AnQiCMS.It not only maintains the consistency of the file format, but also facilitates the recognition and highlighting by the editor.When editing template files, please ensure that the file encoding is set to UTF-8, especially for Windows users, to avoid garbled text on the page.
The organization pattern of template files: flexible to adapt to different needs
Within each theme package, AnQiCMS supports two main template organization modes to accommodate different development habits and project scales:
Folder organization mode:In this mode, template files are stored in different subfolders according to their function or content type, with a clear structure and easy to manage. For example:
- Common part:
bash.html(Contains header, footer, and other common code for reference by other templates). - code snippets:
partial/Contents (for example)partial/sidebar.htmlUsed for sidebar,partial/breadcrumb.htmlUsed for breadcrumb navigation). - Home:
index/index.html. - Model-related pages:
{模型table}/index.html(Model Home Page){模型table}/detail.html(Document Details Page){模型table}/list.html(Document list page). - single page:
page/detail.html. - Special Page:
comment/list.html(Comment List Page)guestbook/index.html(Online Message Page)search/index.html(Search Page)、tag/index.html(Tag Home Page)、errors/404.html(404 Error Page) etc.
- Common part:
Flattened file organization mode:In this mode, all template files are directly stored in the root directory of the theme package, and the file names will include their functions or content types, which is suitable for small projects or users who prefer a simple file structure. For example:
- Common part:
bash.html. - code snippets:
partial/Table of contents (same as above). - Home:
index.html. - Model-related pages:
{模型table}_index.html/{模型table}_detail.html/{模型table}_list.html. - single page:
page.html. - Special Page:
comment_list.html/guestbook.html/search.html/tag_index.html/errors_404.htmletc.
- Common part:
It is worth mentioning that AnQiCMS also allows the definition of specific content.Custom template nameFor example, if you have an article with ID 10, you can create a name for it that{模型table}/detail-10.htmlindependent template; or for a single page "About Us", you can name its template aspage/about.htmlThis is associated in the background. This high degree of flexibility allows you to personalize the display of any specific content on the website.
Mobile end template:mobile/Subdirectory
To support mobile adaptation or an independent mobile site, AnQiCMS provides a dedicated mobile template storage location. You can create one in your theme package directory.mobile/Subdirectory. Thismobile/The directory structure and file naming conventions are consistent with the main site template, which can be folder organization mode or flat mode. When the system detects that the user accesses through a mobile device, it will load it preferentiallymobile/The corresponding template under the directory.
Static resources: stored independently/public/static/
Differing from the template file, the static resources (CSS, JavaScript scripts, images, etc.) required by the website should not be mixed with the template file. AnQiCMS specifies that these static resources should be placed separately in the root directory of the website./public/static/In the catalog. This separation helps improve website performance, facilitate CDN acceleration, and make the project structure clearer.
Mastering these about the storage location and naming rules of AnQiCMS template files, you can organize website customization and frontend development more systematically.
Frequently Asked Questions (FAQ)
Q1: Besides.htmlCan I use other file extensions as template files?A1: No. AnQiCMS template engine only recognizes and processes.htmlThe file with the extension is used as a template. If you use other suffixes, the system will not be able to parse it as a template.
Q2: What will happen if I place the template file in the wrong directory?A2: If the template file is not stored in the specified path, AnQiCMS will not be able to find the corresponding template.This usually causes the page to display incorrectly or directly return a 404 error.When modifying or creating a template, please ensure that the file path and naming are checked carefully.
Q3: How should I refer to the CSS or JavaScript files in the theme?A3: You should place your CSS, JS files in the root directory of your website./public/static/In the directory (or its subdirectory). When referencing in the template, you can use the absolute path relative to the root directory of the website, for example<link rel="stylesheet" href="/static/your_theme/css/style.css">. AnQiCMS provides{% system with name="TemplateUrl" %}The tag can help you dynamically obtain the static file address of the current topic, thereby making it more flexible to construct resource paths.