How to configure different content display templates for mobile and PC separately?

Calendar 👁️ 94

In website operation, providing a browse experience for different devices is crucial.AnQi CMS knows this, it provides a flexible template mechanism that allows you to easily configure different content display templates for mobile and PC terminals, thus meeting user needs and improving website performance.

Below, let's take a detailed look at how to achieve this goal in Anqi CMS.

Understand the template pattern of Anqi CMS.

AnQi CMS provides three main website modes to meet the needs of mobile and PC content display in different scenarios:

  1. Adaptive Mode (Responsive)This is the most common pattern at present. You only need a set of templates, through CSS media queries (Media Query) and flexible layout design, so that the website content can intelligently adjust the display according to the screen size of the user's device.The advantages of this model are the low maintenance cost, a single codebase for all devices, but it may not be as precise in displaying for different devices in extreme cases.

  2. Code Adaptation mode (Code Adaptation)In this mode, although the website is still accessed through the same domain, the security CMS will automatically judge according to the user's access device (PC or mobile) and load different template files.This means you can design two completely independent template codes for the PC and mobile端, with finer control, without worrying about domain redirection issues.

  3. PC+mobile independent sites mode (PC + mobile independent sites)This mode provides you with the greatest flexibility. You can configure completely independent domain names for PC and mobile (for examplewww.yourdomain.comused for PC,m.yourdomain.comUsed for mobile), and independent templates are developed for them. Anqi CMS will intelligently jump and load templates based on the access domain and device type, realizing true independent operation.

Select the appropriate mode

The mode you choose depends on your specific needs and resources invested:

  • If the structure of your website content is relatively simple, and you hope to minimize maintenance coststhenAdaptive modeIt is a very good choice. Modern browsers have very mature support for responsive design, a well-designed responsive template is enough to deal with most scenarios.
  • If your mobile and PC end needs to display a content structure or design style that differs significantly, and you want to have finer control over both, but do not want to manage two separate domainsthenCode Adaptation ModeIt would be the ideal choice. It allows you to provide a customized user experience for mobile and PC platforms while maintaining a single domain entry.
  • If your business scenario requires mobile and PC端 to have a completely independent brand positioning, content strategy, even user groups, and are willing to invest more resources to maintainthenPC + mobile independent site modeWill provide you with ultimate flexibility and customization capabilities. This model is common in large enterprises or websites in specific vertical industries.

Configure different content display templates for mobile and PC

Next, let's take the "code adaptation mode" and "PC + mobile independent site mode" as examples, and see how to configure it specifically in AnQi CMS.

Step 1: Make global settings in the background

No matter which independent template mode you choose, you need to make the corresponding configuration in the Anqi CMS background and tell the system your template strategy.

  1. Confirm template type First, you need to open the folder of the template you are currently using (usually located/template/你的模板目录/) underconfig.jsonfile. In this file, you need to settemplate_typethe value of the field:

    • If you chooseAdaptive mode, willtemplate_typeis set to0.
    • If you chooseCode Adaptation Mode, willtemplate_typeis set to1.
    • If you choosePC + mobile independent site mode, willtemplate_typeis set to2.

    This setting is to inform AnQi CMS of the overall adaptation strategy of this template.

  2. Configure the mobile end address (only for PC + mobile independent site mode)If you select the "PC+Mobile Independent Site Mode", then in the "Global Settings" backend, find the "Mobile End Address" option, enter the independent domain name you have prepared for the mobile end (for examplem.yourdomain.com). Make sure that this domain is correctly resolved to your server. Anqi CMS will automatically determine and redirect to the corresponding domain based on the device used by the user.

Step two: Organize your template file structure

The template file organization of Anqi CMS is very intuitive. In your template directory (for example/template/default/) you need to create a file namedmobile.

  • PC template: All PC template files (such asindex/index.html/{模型table}/detail.html/{模型table}/list.html) will be placed directly in your main template directory.
  • Mobile end template: The mobile template files corresponding to the PC template will be placed inmobile/In the subdirectory, keeping the same directory structure and file name. For example, if your PC homepage template isindex/index.html, then the mobile homepage template should bemobile/index/index.html.

In this way, when the system detects that it is a mobile device accessing, it will load preferentiallymobileThe templates under the directory; if it is a PC device, then load the files under the main template directory.

For example:

/template/your_theme/
├── config.json         # 包含 template_type 设置
├── index/
│   └── index.html      # PC端首页
├── article/
│   └── list.html       # PC端文章列表
│   └── detail.html     # PC端文章详情
├── page/
│   └── detail.html     # PC端单页面
└── mobile/
    ├── index/
    │   └── index.html  # 移动端首页
    ├── article/
    │   └── list.html   # 移动端文章列表
    │   └── detail.html # 移动端文章详情
    └── page/
        └── detail.html # 移动端单页面

The third step: refine to page-level template configuration

AnQi CMS also provides more fine-grained control, allowing you to specify different display templates for individual documents, categories, or single pages.This is very useful when certain content needs unique display, even when the overall choice is 'code adaptation' or 'PC + independent mobile site' mode, these local settings are also applicable.

  1. Document TemplateWhen editing an article or product, you can find the 'Document Template' option in the 'Other Parameters'. Here you can enter a custom template filename (such asdownload.html),AnQi CMS will use this specific template to display this document. If you create one for both PC and mobile endpointsdownload.htmlandmobile/download.html,the system will automatically load the corresponding version based on the device.

  2. category templateIn editing category information, you can set "category template".This allows you to specify a unique list page or detail page template for a specific category (and all documents under it if the 'Apply to subcategories' option is checked).For example, you can set up a category for "news"news_list.htmlSet as 'Product' categoryproduct_list.html.

  3. Single page templateFor pages like "About Us", "Contact Information", etc., you can also specify the "Single Page Template" during editing.This is very convenient for creating a standalone page with specific layout or functionality.

These page-level template settings will override the global template rules, bringing great flexibility to your content operation.

Other considerations

  • Static resourcesEnsure the path is correct when referencing images, CSS, JavaScript, and other static resources in your template. Anqi CMS usually places static resources in/public/static/Under the directory, and through the template{{system with name="TemplateUrl"}}Label to obtain the template static file address, ensuring that the correct resources can be found regardless of which template is loaded
  • Content Management: Although the template separates the display, the content behind the scenes is managed uniformly.This means you don't need to publish content separately for PC and mobile platforms.If you need to display on different devicesDifferentiationThe content may need to consider adding custom fields in the content model, and displaying them through logical judgments in the template (for example{% if isMobile %}{{"移动端内容"}}{% else %}{{"PC端内容"}}{% endif %})
  • SEO optimizationFor PC+mobile independent site mode, make sure you have configured it correctlyhreflangtags (if there is a need for multilingual support) andcanonicalTags to tell search engines which pages are the main version, avoiding duplicate content issues. Anqi CMS provides in the TDK tags.CanonicalUrlThe call can help you handle this kind of work.

The AnQi CMS provides high flexibility in multi-terminal template configuration, allowing you to easily implement various configurations from simple responsive to fully independent sites according to your actual needs.Mastering these features will help you provide a better user experience and contribute to the success of website operations.


Frequently Asked Questions (FAQ)

1. If I selected the "Code Adaptation" mode but did not inmobileWhat will happen when the corresponding mobile template file is created in the directory?Answer: In this case, when the mobile device accesses, the Safe CMS will try to findmobileThe corresponding template under the directory, if not found, it will usually fallback to loading the PC template file.This could result in poor display on mobile devices, as PC templates are usually not suitable for direct display on small screens.Therefore, it is recommended to create corresponding mobile templates for all pages that need to be distinguished when enabling code adaptation mode.

2. Can I use both 'Adaptive' and 'Code Adaptation' strategies in the same template?Answer: Yes, that is possible. You can adapt the template'stemplate_typeis set to1(Code adaptation mode), thenmobilePlace the mobile template in the directory. At the same time, your PC template itself can also be designed to be responsive.This, PC users will get a responsive experience, and mobile users will get a mobile template experience designed specifically for you.This provides you with the ability to flexibly combine different front-end strategies across different devices.

3. If there is a significant difference between the content of my mobile and PC end, even needing different SEO strategies, can Anqi CMS support it?Of course you can. When you choose the "PC+Mobile Independent Site Mode", you can configure completely independent domains for mobile and PC endpoints.This means you can manage almost all content details for them separately, including different TDK (Title, Description, Keywords), different content models (if needed), and completely different templates and designs.Although content publishing still takes place on the same backend, but by fine-tuning at the template level and distinguishing fields in backend management, you can achieve

Related articles

How can I customize a template for a specific category or page to control the display style?

When operating a website, we often encounter situations where different types of content, even articles in the same category or different "About Us" pages on the same website, hope to have a unique display style to better attract readers and convey information.AnQiCMS (AnQiCMS) is well aware of this need and therefore provides a very flexible template customization mechanism, allowing us to easily tailor the display style for specific categories or pages.The Anqi CMS template system is based on the Django template engine syntax in Go language, which means that as long as you have a basic understanding of front-end development

2025-11-08

Does the background template editing function support real-time preview of content display effects?

AnQi CMS is favored by many operators for its efficient and flexible features in the field of website content management.When we talk about the visual presentation and user experience of a website, the customization capabilities of the template are undoubtedly the core.Among them, the real-time preview of the background template editing function and the display effect of the content is a focus for many users. ### The template editing capability of AnQi CMS: powerful and flexible AnQi CMS provides users with powerful and flexible backend template editing functions.The system uses a template engine syntax similar to Django, which is understandable for users familiar with front-end development or template languages

2025-11-08

How to display the Tag tag list of articles or products in AnQiCMS?

In Anqi CMS, flexibly displaying the Tag tag list of articles or products is a key link to improving the organization of website content and user experience.By carefully designed tags, it can not only help visitors quickly find the content they are interested in, but also effectively optimize search engine crawling and improve the website's SEO performance.Today, let's delve into how to fully utilize the Tag feature in AnQiCMS to revitalize the content of your website.### Understanding AnQiCMS Tag Tags In the AnQiCMS management background

2025-11-08

How does the new content model feature enhance the flexibility of content display?

In today's rapidly changing digital world, the content carried by websites is no longer just simple articles and product introductions.From an exciting online event, a detailed customer case, to a professional team introduction, and a complex service process, each type of content has its unique attributes and presentation methods.If your content management system (CMS) still only uses the universal templates of "article" or "product" to publish all information, it will undoubtedly bring many limitations to content creation and display.

2025-11-08

What file extension should AnQiCMS template files use to ensure correct display?

When using AnQiCMS for website construction and content management, ensuring that the template files are displayed correctly is the foundation for the normal operation of the website.This is where, the naming convention of template files, especially the file extension, plays a crucial role. The template files of Anqi CMS have a clear and unified file extension requirement, which is to use **.html** as the file extension of the template files.These files are usually organized in the `/template` folder under the root directory of the website.Choose `.html`

2025-11-08

How to display variables in AnQiCMS templates?

In AnQiCMS templates, how to effectively display variable data is a core skill that every website operator and template creator needs to master.AnQiCMS uses a syntax similar to the Django template engine, making data calls and display both intuitive and flexible.This article will delve into various ways to display variables in AnQiCMS templates, helping you accurately present dynamic information such as backend configuration data and article content on the website front-end.

2025-11-08

How to use conditional judgment and loop control to dynamically adjust the display of content?

In Anqi CMS, we often encounter scenarios where we need to display different information based on specific conditions or repeat a series of contents.At this time, by flexibly using conditional judgment and loop control, the website content can become more vivid and intelligent.The AnQi CMS template feature provides powerful syntax support similar to the Django template engine, through these tags, we can easily achieve dynamic content adjustment without writing complex background code. ### Conditional judgment: Make the content 'speak to people' Conditional judgment is the basis for dynamic content display.Imagine

2025-11-08

Why is UTF8 encoding crucial for the display of content in AnQiCMS templates?

## Content display no longer troubles: Why is UTF-8 encoding so critical for AnQiCMS templates?In the process of building and operating a website with AnQiCMS, we often strive for the website's efficiency, stability, and diverse display of content.However, there is a seemingly basic but actually crucial link that, if not handled properly, will cause all our efforts to be wasted - that is the character encoding of the template file.Especially for AnQiCMS, UTF-8 encoding is not just a recommendation, it is the core foundation to ensure that website content is displayed correctly and clearly.

2025-11-08