In the AnQiCMS world, 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,template_typefield.

Explore the mysteryconfig.json: The 'Identity Statement' of the template

When we create or select a template for an AnQiCMS website, we will find a file namedconfig.jsonEnglish file. This file is the 'manifesto' of the template, which includes the name of the template (name), package name (package), version number (version), author (authorEnglish metadata.This information helps the system identify and manage templates.It is like a detailed resume that allows the system to understand the basic attributes of the template.config.jsonand there is also a file namedtemplate_typeThe field is the key to determining the overall display mode of the website.

template_typeThe field value directly tells AnQiCMS how your website template will adapt to the accessing devices, which affects user experience, SEO effect, and subsequent maintenance costs. It has three main values, each representing a different display mode:

模式0:自适应(English)

Whentemplate_typeset0At this point, it means 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 access device 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 for the characteristics of the device.

Advantages:Maintenance costs are relatively low because you only need to maintain a single codebase; at the same time, it is SEO-friendly because all devices share the same URL, avoiding issues with duplicate content.Consideration factors:High CSS skills are required for front-end developers, and careful design is needed to maintain a good experience on all screen sizes.

模式1:代码适配(Code Adaptation)

Choose1Represents code adaptation mode.This pattern goes one step further than pure adaptability, allowing you to provide a set of dedicated code or style optimizations for mobile devices on top of the main template.mobile/子目录。如果mobile/The template file corresponding to the catalog exists (and the template is designed for mobile devices), the system will load the mobile version of the template.)mobile/The corresponding move template was not found in the catalog, and it will revert to loading the main template.

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

模式2:电脑+手机独立站点(PC + Mobile Independent Sites)

Whentemplate_typeset2When, your website will be fully differentiated between PC and mobile end.This means you need to design and maintain two separate templates for the PC and mobile versions.mobile/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, for example). For example, you can configure the main site.www.yourdomain.comEnglish for mobile site configurationm.yourdomain.com(and linked through the "Mobile End Address" field in system settings).

Advantages:Can provide the most customized experience and performance optimization for different devices, with completely different designs and functions on PC and mobile ends, without interference.For websites that require deep SEO optimization for different platforms, this model is very powerful.Consideration factors:The development and maintenance costs are the highest, you need to manage and update two sets of independent template codes. At the same time, attention should be paid to the relevance of PC and mobile content in SEO, for example, bycanonicalLabel the content to avoid misjudgment as duplicate by search engines.

How to set uptemplate_type?

To modify the display mode of the website, you just need to edit the current template directory.config.jsonthe file. Findtemplate_typeField, and change its value to0/1or2One of them is. 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 background, click the 'Update Cache' function to ensure that the new configuration takes effect immediately.

Summary

Correct choicetemplate_typeIt is crucial for the operation of your AnQiCMS website.An appropriate pattern can significantly enhance user experience, ensuring that content is perfectly displayed 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 reasonable choices can meet business needs while effectively controlling development and maintenance costs.Deeply understand and make reasonable use of this field, which will help your AnQiCMS website stand out in the fierce online competition.


Common 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 prioritize choosingPattern 0 (Adaptive).It maintains simplicity, is SEO-friendly, and can meet the needs of most modern websites.Pattern 1 (Code Adaptation).Pattern 2 (Computer + Mobile Independent Sites)通常适用于对PC和移动端有极致差异化需求,且预算充足的专业团队。

2. 切换template_type后,我的网站内容会丢失吗?

切换template_typeThe field itself will not cause the loss of website content.This field only affects the way AnQiCMS loads templates.mobile目录(当template_typeresponse for1or2It may cause the website to display abnormally or be disorganized in layout.Therefore, it is strongly recommended that you thoroughly test in a test environment before switching modes, and ensure that the template you choose supports the display mode you need.

3. If I selected代码适配(1)or电脑+手机独立站点(2)but did not createmobilea directory, what would happen?

If selectedPattern 1 (Code Adaptation)but notmobileCatalog, the system will directly load the main template on mobile devices.This is equivalent to falling back to adaptive mode, your website can still be accessed, but may lack deep optimization for mobile devices.Pattern 2 (Computer + Mobile Independent Sites)but notmobileThe catalog, when accessed on a mobile device, will not find the corresponding template file. This may very likely cause the website to not display properly on mobile devices, or even result in error pages. Therefore, in both modes, in order to ensure the normal operation and good experience of the website,mobileCatalog and its internal mobile端