How does the `template_type` field in `config.` control the overall display mode of the AnQiCMS website?

Calendar 👁️ 64

In the world of AnQiCMS, each template has a configuration file like an ID card——config.json. It not only records the basic information of the template, but also carries a crucial setting, that is, how to determine the presentation of your website on different devices. This setting is thattemplate_typefield.

Exploreconfig.json: The "Identity Statement" of the template

When creating or selecting a template for an AnQiCMS website, you will find a file named in the root directory of the templateconfig.jsonThe file. This file is the 'manifesto' of the template, which includes the name of the templatename), package namepackage), version numberversion), authorauthorThis metadata helps the system identify and manage templates.It is like a detailed resume that allows the system to understand the basic properties of the template.However, besides this basic information,config.jsonThere is also a namedtemplate_typeThe field is truly the key to determining the overall display mode of the website.

template_typeThe value of the field, directly tell AnQiCMS how your website template will adapt to the visiting device, thus affecting user experience, SEO effect and subsequent maintenance cost. It has three main values, each representing a different display mode:

Pattern 0: Responsive

Whentemplate_typeis set to0At this point, it means that you have adopted the most common adaptive design. In this mode, your website uses a set of HTML code and CSS styles, intelligently identifying the screen size and resolution of the device being accessed through technologies such as CSS media queries (Media Queries), and then automatically adjusting the layout and content.No matter whether the user accesses through a computer, tablet, or smartphone, they see the same set of code, which is optimized in form according to the characteristics of the device.

Advantage:The maintenance cost is relatively low because you only need to maintain a single codebase; it is also SEO-friendly as all devices share the same URL, avoiding the issue of duplicate content.Considerations:High requirements for frontend developers' CSS skills, careful design is needed to maintain a good experience on all screen sizes.

Pattern 1: Code Adaptation

Select1Represents the code adaptation mode. This mode goes a step further than pure adaptation, allowing you to provide a set of dedicated code or style optimizations for mobile devices.In particular, when the system detects that the user is using a mobile device, it will first look for the template directory belowmobile/Subdirectory. Ifmobile/The directory contains a corresponding template file (and the template is designed for mobile devices), the system will load the mobile version of the template. Ifmobile/The corresponding move template was not found in the directory, and it will fallback to loading the main template.

Advantage:Provided stronger mobile customization capabilities than pure adaptation, and can perform deeper optimization for mobile devices without fully independent two sets of sites.Considerations:The maintenance workload will be slightly higher than the adaptive mode, as it requires managing the main template and possibly the existing mobile adaptation template.

Model 2: PC + Mobile Independent Sites

Whentemplate_typeis set to2At that time, your website will completely differentiate between PC and mobile end. This means that you need to design and maintain two independent templates separately for PC and mobile end.Generally, PC templates are placed in the main template directory, while mobile templates must be stored inmobile/Under the directory. The system will automatically load the corresponding template based on the type of the user's device (judged by the browser User-Agent information, etc.). For example, you can configure the main site.www.yourdomain.comSet for mobile station configurationm.yourdomain.com(And link it through the "Mobile End Address" field in the system settings).

Advantage:Provide the most optimized customized experience and performance optimization for different devices, with completely different designs and functions for PC and mobile terminals, without interfering with each other.For websites that need deep SEO optimization for different platforms, this model is very powerful.Considerations:The development and maintenance costs are the highest, you need to manage and update two independent template codes. At the same time, SEO needs to pay attention to the relevance of PC and mobile content, such as throughcanonicalLabel to point, to avoid search engines misjudging it as duplicate content.

How to settemplate_type?

To modify the display mode of the website, you just need to edit the current template directory under.config.jsonFile. Find.template_typeField, and modify its value0/1or2One of them. For example:

{
	"name": "我的响应式模板",
	"package": "my_responsive_theme",
	"version": "1.0",
	"description": "一个优雅的自适应模板",
	"author": "Your Name",
	"homepage": "https://yourwebsite.com",
	"created": "2023-10-27 10:00:00",
	"template_type": 0, // 修改此值
	"status": 1
}

Modify and saveconfig.jsonAfter the file, please log in to the AnQiCMS backend, click the 'Update Cache' feature to ensure that the new configuration takes effect immediately.

Summary

Correct selectiontemplate_typeIt is crucial for the operation of your AnQiCMS website. A suitable model can significantly improve user experience and ensure that content displays perfectly on various devices;At the same time, it also directly affects the search engine's crawling and ranking of the website, thereby determining the traffic performance of the website.It is more important that a reasonable choice can meet business needs while effectively controlling development and maintenance costs.Deeply understand and reasonably apply this field, it will help your AnQiCMS website stand out in the fierce online competition.


Frequently Asked Questions (FAQ)

1. My website is new, which one should I choose?template_type?

If you are just starting to build a website and have limited front-end development skills or want to save costs to the maximum extent, it is recommended to choose first.Pattern 0 (Adaptive)It maintains simplicity, SEO-friendly, and can meet the needs of most modern websites.If you need to provide some independent styling or structural optimization for mobile, but do not want to completely separate two sets of code, you can tryPattern 1 (Code Adaptation).Pattern 2 (Computer + Mobile Independent Site)It is usually suitable for professional teams with extreme differentiation requirements for PC and mobile devices and sufficient budget.

2. Switchtemplate_typeAfter that, will my website content be lost?

Switchtemplate_typeThe field itself will not cause the website content to be lost. This field only affects the way AnQiCMS loads templates.But if your new template does not adapt to the content structure of the old template or does not create the correspondingmobileContents (whentemplate_typeWith1or2It may cause the website to display abnormally or be disorganized in layout.Therefore, it is strongly recommended that you thoroughly test in the test environment before switching modes and ensure that the template you choose supports the display mode you need.

3. If I chose代码适配(1)or电脑+手机独立站点(2), but did not createmobileWhat if the catalog?

If you choosePattern 1 (Code Adaptation)withoutmobileThe directory, the system will directly load the main template on mobile devices.This is equivalent to degrading to adaptive mode, your website can still be accessed, but may lack in-depth optimization for mobile devices.If selectPattern 2 (Computer + Mobile Independent Site)withoutmobileThe directory, when accessed on a mobile device, may not find the corresponding template file, which may cause the website to not display normally on mobile devices, or even result in error pages. Therefore, in these two modes, in order to ensure the normal operation and good experience of the website,mobileMobile end and its internal directory

Related articles

How does AnQiCMS automatically apply the display style of a specific category or page through the default custom template name?

In the daily use of AnQiCMS (AnQiCMS), the flexibility of templates is one of the key factors in improving content operation efficiency.For many website managers, how to make specific content - whether it is an article, a product, a category page, or an independent single page - have a unique display style while avoiding cumbersome repetitive configuration is a common requirement.AnQi CMS solves this problem through a clever default custom template naming mechanism, enabling efficient collaboration between content operations and front-end design.### AnQiCMS

2025-11-08

How to implement separate mobile content display and adaptation in the AnQiCMS `mobile` template directory?

In today's mobile internet era, the mobile experience of a website has become an important standard for measuring its professionalism and user-friendliness.With the popularity of smartphones and tablet devices, there is an increasing demand for users to access website content smoothly on various screen sizes.AnQiCMS (AnQi CMS) deeply understands this trend and provides flexible and diverse mobile adaptation solutions, among which the design of the `mobile` template directory is the core secret to creating a dedicated mobile experience.###

2025-11-08

The UTF-8 encoding requirements of AnQiCMS template, how to ensure the normal display of multilingual content (such as Chinese)?

AnQiCMS (AnQiCMS) is a system focused on providing an efficient and customizable content management solution, with its powerful multilingual support function, it provides convenience for expanding the global market of the website.When using AnQiCMS to build a website containing Chinese or other non-ASCII character content, ensuring that these contents are displayed normally and avoiding garbled text is a fundamental and critical step.This is particularly important for the UTF-8 encoding requirement of the template file.The importance of UTF-8 encoding in template files Anqi CMS when handling template files

2025-11-08

How to standardize the use of variables and control tags in AnQiCMS templates to ensure the correct display of content?

In AnQiCMS (AnQiCMS), the template is the core of website content display.Whether it is to build a corporate website or operate a content-rich blog, the correct display of content is inseparable from the standardized use of variables and control tags in the template.Mastering these basic knowledge can not only help us flexibly customize the website interface, but also effectively avoid potential display errors, ensuring the stable and efficient operation of the website.The template syntax design of Anqi CMS draws inspiration from the Django template engine, its core lies in distinguishing variable output and logical control.Variables are usually enclosed in curly braces

2025-11-08

How to achieve consistent content display in the `bash.html` and `partial/` public code files of the AnQiCMS template?

In website operation, maintaining consistency in content display is the key to improving user experience, strengthening brand image, and simplifying maintenance work.AnQiCMS (AnQiCMS) provides a powerful mechanism in template design, through the `bash.html` file and `partial/` directory, etc., public code structure, helps operators easily achieve the unified and efficient management of the entire site content display.Imagine your website as a meticulously constructed house.To ensure the overall beauty and functionality of the house, we will not redesign the doors and windows or the roof in every room. Instead,

2025-11-08

How to specify a specific display template for the homepage, detail page, list page, etc. of the AnQiCMS website?

When building a website, we often need to assign unique appearances and functions to different page types, such as the grand layout of the homepage, the immersive reading experience of the article detail page, or the filtering and display of the product list page.AnQiCMS provides a flexible mechanism that allows users to easily specify and manage display templates for each page of the website.This has greatly enhanced the customization of the website, as well as greatly optimized the user experience and content presentation efficiency. The template files of AnQiCMS website are uniformly stored in the `/template` directory. Usually

2025-11-08

How does AnQiCMS's flat file organization pattern simplify template management and optimize the content display process?

In website operation, template management is a key link that balances efficiency and experience.A well-designed, easy-to-maintain template system that can greatly enhance the speed of website content publishing and the flexibility of page updates.AnQiCMS provides unique solutions in this field, especially its 'flat file organization mode', which brings practical convenience to users in simplifying template management and optimizing the content display process.### Say goodbye to layered nesting: The charm of AnQiCMS flat file organization In many traditional content management systems, template files are often buried deep in a multi-level directory structure

2025-11-08

How to customize independent display templates for single pages such as 'About Us' to meet specific display requirements?

In Anqi CMS, in order to make single pages like "About Us" and "Contact Us" have unique display effects, rather than following the unified page layout of the website, we can customize independent display templates for them.This customized capability is a reflection of the flexibility of Anqi CMS, which can help us better shape our brand image, or provide a more suitable display form for specific content.### Overview of AnQi CMS Template Mechanism The AnQi CMS template system is designed to be very intuitive and powerful, based on syntax similar to the Django template engine, which separates the presentation of content from logical control.

2025-11-08