How to define a new template, what is the role of the `config.` file?

Calendar 👁️ 67

As an experienced CMS website operation personnel of an enterprise, I know that a flexible and efficient template system is crucial for the presentation of website content and user experience.The AnQi CMS was designed with full consideration of the customizability and ease of use of the templates, allowing both beginners and experienced developers to easily master it.Next, I will elaborate on how to define a new template in Anqi CMS and analyze it in depthconfig.jsonThe file plays a core role in this process.

To define a new template for AnQi CMS, first you need to be in the root directory of the system./templateCreate a new subdirectory in the folder. The name of this subdirectory will represent your new template, for example, you can name itmy_new_themeorcorporate_design. This new folder is the base location where all files of your new template are stored.

There is a crucial file in the root directory of the new template, that isconfig.json. This file is the 'ID card' and 'instruction manual' of the template, it informs the Anqi CMS system of the basic information, type, and status of the template. It can be said that there is noconfig.jsonFile, your new template cannot be recognized and loaded correctly by the system.

Let's learn more in detail.config.jsonThe role of each field in the file:

in the filenameThe field is used to specify the display name of the template, which is usually the name seen by the user in the back-end management interface, such as 'Default Template' or 'Corporate Official Website Style'.packageThe field is the unique identifier for the template, corresponding to the one you create in/templatethe directory, and it only supports letters and numbers.versionThe field allows you to customize the version number of the template, which is convenient for you to manage the iterative updates of the template.descriptionThe field provides a brief description of the template features, allowing other users or future you to quickly understand the characteristics of the template.

To clarify the ownership and origin of the template,authorThe field is used to fill in the author information of the template, whilehomepagethe field can provide the author's website link.createdThe field records the creation time of the template, in accordance with2022-05-10 22:29:00such a specific format.

template_typeIsconfig.jsonA very critical setting that determines the template adaptation mode. Anqi CMS supports various adaptation modes including0representing the adaptive mode (templates automatically adjust the layout on different devices),1Represents the code adaptation mode (requires writing different HTML structures for PC and mobile), as well as2The computer + mobile independent site mode (PC and mobile end have completely independent template files, and usually also cooperate with independent mobile domain).Choose the appropriate template type to ensure your website provides a good browsing experience across different devices.

Finally,statusfield indicates the enabled state of the template. The optional values are0(disabled) or1(In use). It should be noted that only one template can be used in all installed templatesstatusThe value is set to1, which means that only one template can be enabled at a time in Anqie CMS.

Onceconfig.jsonThe file configuration is complete, next is to build the specific file structure of the template.AnQi CMS provides two main template organization modes: 'Folder Organization Mode' and 'Flattened File Organization Mode'.

Under the "folder organization mode", template files are categorized into different subfolders according to their functions and content types, for exampleindex/index.htmlUsed for the homepage,{模型table}/detail.htmlUsed for document detail pages,partial/The catalog stores reusable code snippets such as headers, footers, and sidebars. This structure helps maintain the clarity and modularization of template files.

Compared to this, the "flattened file organization pattern" places all the main template files directly under the root directory of the template, for exampleindex.htmlrepresents the home page,{模型table}_detail.htmlRepresents the document detail page. This pattern may be more suitable for small or simple website templates.

No matter which organizational pattern you choose, if yourtemplate_typeSet to code adaptation or PC + mobile independent site mode, you need to create one in the template root directorymobile/The subdirectory, and copy the mobile template files similar to the PC template structure within it. In this way, the AnQi CMS can automatically load the corresponding template according to the user's access device.

The AnQi CMS also supports more fine-grained template specification for specific content items (such as document details, category pages, or single pages). This means you can create a template for the "About Us" page.page/about.htmlThis is a dedicated template, and it is associated with the corresponding single page in the background management interface. This greatly enhances the flexibility of the template and the personalized display of content.

In short,config.jsonThe file is the starting point for defining a new template, providing all necessary information for the security CMS to identify, classify, and manage templates. Proper configuration throughconfig.jsonFollow the template organization conventions, and you will be able to fully utilize the powerful functions of Anqicms, creating highly customized and user-friendly websites.

Frequently Asked Questions

Q1: If myconfig.jsonIf the file is missing or the configuration is incorrect, how will the system handle it?Ifconfig.jsonIf the file is missing or one of the key fields (such aspackageornameIncorrect configuration, the Anqi CMS system will not be able to correctly identify and load your template, which may cause the website to display incorrectly, or the template may not be found in the background template management list.The system usually reverts to the default template or displays an error message.Therefore, ensureconfig.jsonFor the template to run normally, it is a prerequisite that the file is always present and the configuration is correct.

Q2: Can I use different template engines or syntax for PC and mobile within the same template folder?No.config.jsonin the filetemplate_typeThe field is set for the entire template package. This means that once you choose a template type (such as adaptive or PC+mobile independent), all the template files in the template package should follow the corresponding design principles and template syntax.The AnQi CMS uses Django template engine syntax, and regardless of the template type you choose, you should use this syntax.For PC+mobile independent mode, although the file structure is independent, they still share the same template engine context.

Q3: I created a new template, but how can I enable it in the background?As soon as you create a new template,config.jsonthe file is configured correctly and placed in/templateUnder the directory, the system usually detects it in the "Template Design" or "Website Template Management" area of the background management interface.You can find your new template on this interface and set it as the currently used template by clicking the enable button.Under the hood, this will typically update the template'sconfig.jsonin the filestatusField is1while enabling other templates'statusfield to be set0.

Related articles

How to create and apply an independent template for a specific single page (such as 'About Us')?

As an experienced website operator who deeply understands the operation of AnQiCMS, I understand that you want to create and apply an independent template for a specific single page (such as "About Us").This not only allows the page content to be displayed more personalized, but also effectively meets specific design and functional requirements.AnQiCMS provides a flexible template mechanism, making this process intuitive and efficient.### A detailed guide to creating and applying independent templates for specific single pages in AnQiCMS AnQiCMS is known for its high customizability and flexibility

2025-11-06

How to customize the document list template for a specific category?

As a website operator who deeply understands the operation of AnQiCMS, I understand your needs for personalized content display and user experience optimization.The document list template under the custom category is the key step to achieve this goal.AnQiCMS provides a flexible template mechanism that allows you to present a unique list layout based on the content features of specific categories.

2025-11-06

What are the naming conventions to follow for a specific document detail page template?

As an experienced security CMS website operations personnel, I deeply understand the importance of the naming rules of the content management system (CMS) template for the long-term operation, maintenance efficiency, and content presentation quality of the website.A clear and standardized template naming not only allows team members to quickly understand the purpose of the file, reduce collaboration costs, but also provides strong flexibility and scalability when the website faces a redesign or feature upgrade.In AnQi CMS, the naming of templates for specific document detail pages follows a set of flexible and hierarchical rules, aimed at meeting the needs of content display at different granularity.

2025-11-06

How can I implement a custom template name so that the system can automatically recognize and apply it?

As an experienced security CMS website operator, I am well aware of the importance of flexible template customization for website content display and user experience.The Anqi CMS, with its concise and efficient architecture, provides us with great freedom to manage and display content.How to implement a custom template name so that the system can intelligently recognize and apply it is the key to improving operational efficiency and meeting the needs of personalized display.

2025-11-06

What are the possible values and their meanings for the `template_type` field in `config.`?

As an experienced CMS website operation personnel, I fully understand the importance of template configuration for the front-end display and user experience of the website.The `config.` file is the core configuration file for each AnQiCMS template, defining its various basic properties and behaviors.Among them, the `template_type` field plays a crucial role, directly affecting the display of the website on different devices.

2025-11-06

How to control the enable status of the template through the `status` field in `config.`?

In the daily operation of Anqi CMS, we often need to adjust the appearance and layout of the website, which usually involves switching or enabling different templates.AnQi CMS provides an intuitive and efficient way to manage the enabled status of templates, which is mainly achieved through the `status` field in the `config.` file under each template directory.

2025-11-06

How should common code snippets like headers, footers, etc. be organized and stored during template creation?

As a website operator familiar with Anqi CMS, I am well aware of the importance of a well-structured and easy-to-maintain template for the long-term healthy operation of the website.How to efficiently organize and store common page headers, footers, and other reusable code snippets during template creation is crucial for improving development efficiency and ensuring website consistency.In Anqi CMS, the template system uses a syntax similar to the Django template engine, which provides us with powerful tools to achieve code reuse and modular management.

2025-11-06

How to create and reference reusable code snippets like sidebars, breadcrumbs, etc. in templates?

As an experienced CMS website operation person in a security company, I am well aware of the importance of efficient content management and flexible template customization for website operation.In daily work, we often need to deal with various page elements, such as sidebars, breadcrumb navigation, headers, and footers, etc., which appear repeatedly on multiple pages.It is crucial to modularize and reuse these commonly used code snippets in order to improve development efficiency, ensure code consistency, and simplify maintenance work.AnQi CMS provides a powerful and easy-to-use template engine, allowing us to easily achieve this goal.

2025-11-06