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