How to display the mobile URL of the website in AnQiCMS template?

Calendar 👁️ 79

When using AnQiCMS to build and manage a website, many friends may encounter the following need: How can you conveniently obtain and display the URL of the independent mobile version of the website in the template?This makes it convenient for users to switch between different devices and also has a positive impact on search engine optimization (SEO).Don't worry, AnQiCMS provides a very intuitive way to achieve this.

Why do we need to display the mobile URL in the template?

First, let's briefly discuss why there is such a need.Among the various website modes supported by AnQiCMS, there is one called "PC+Mobile independent site mode".This means your website may have two independent URLs, one for desktop (PC) and another specifically designed for mobile devices.This separation is usually to provide a more optimized mobile user experience, such as faster loading speed, a simpler layout, or optimization for touch operations.

In this mode, you may wish to provide a clear link in the footer of the desktop website, in some navigation menu, or even by intelligently judging the user's device to guide users to the corresponding mobile site.This not only improves the user experience, but also helps search engines better understand and index your website structure, especially when dealing with Hreflang tags or Canonical tags. The correct mobile URL information is crucial in this case.

Step 1: Set the mobile end address in the AnQiCMS backend

Before starting template development, we need to make sure that the mobile website URL is correctly configured in the AnQiCMS backend.

  1. Log in to the backend:Access your AnQiCMS backend management interface.

  2. Enter global settings:In the left menu, find "Backend Settings", click to expand and select "Global Function Settings".

  3. Configure mobile end address:On the "Global Function Settings" page, you will see an input box named "Mobile End Address". Here, be sure to fill in the complete URL of your mobile website, for examplehttps://m.yourdomain.com.

    Please note that this address must be accessible and your domain must be correctly resolved to the server.This is the key step to ensure that your mobile website can be correctly identified and accessed.If your website is responsive design, you do not need a separate mobile URL, then this field can be left blank.

Step 2: Call the mobile URL in the AnQiCMS template

The AnQiCMS template system is very flexible, it retrieves and displays various types of information configured on the back-end through tags. For information in the global settings of the system, we usually usesystemtags to obtain.

systemThe tag is used to get system-level configuration information from the background, and the mobile end URL we need is exactly one of them.

The following is the method to display the mobile end URL in the template.

You can directly use{% system with name="MobileUrl" %}This tag will directly output the mobile end address you set in the background.

For example, if you want to place a link in the footer of the website to guide users to the mobile version, you can write it like this:

<a href="{% system with name="MobileUrl" %}" class="mobile-version-link">访问手机版</a>

If you want to assign the obtained mobile URL to a variable for more flexible use in the template, you can do it like this:

{% set mobileSiteUrl = system with name="MobileUrl" %}
<a href="{{ mobileSiteUrl }}" class="mobile-version-link">访问手机版</a>

This, when the user clicks on this link, will be directed to the mobile end website you specify.

Tips for practical application scenarios

  • Header/Footer links:The most common application is to add a link to a "mobile version" or "mobile site" at the top or bottom of a website, making it convenient for users to manually switch.
  • Hreflang tag:If your site has internationalization or regionalization needs, and the mobile also corresponds to these languages or regions, you can use thisMobileUrlwithhreflangUsing tags together, notify the search engine that your page has a corresponding mobile version. Although AnQiCMS'slanguagesThe tag is more suitable for managing multilingual URLs, but this URL is still useful if you need to specifically point out the corresponding PC site for a mobile site.
  • JavaScript Smart Jump:For more advanced requirements, you can use JavaScript to determine the user's device type when the page loads. If it detects a mobile device and the current access is through a PC-end URL, JavaScript can redirect the user to access throughsystem with name="MobileUrl"The mobile end URL obtained. However, this logic requires additional JavaScript code to be written and carefully tested to avoid unnecessary redirect loops or compatibility issues.

By following these steps, you can easily display and utilize your website's mobile URL in the AnQiCMS template.The design of AnQiCMS aims to make content management simple and efficient, flexibly using these built-in tags will bring great convenience to your website operation.

Frequently Asked Questions (FAQ)

Q1: How do I set up a mobile URL but it does not display on the front-end template or displays incorrectly?A1: First, please check that the 'Mobile Endpoint Address' in the 'Global Function Settings' backend is correctly filled in without any extra spaces. Next, confirm that you are usingsystemThe label is spelled correctly, especiallyname="MobileUrl"ofMobileUrlDo the case match. AnQiCMS template tags strictly distinguish between uppercase and lowercase. Finally, please clear the AnQiCMS system cache to ensure that the latest configuration has taken effect.

Q2: I set up the mobile URL, but why doesn't it automatically redirect to the mobile website when accessed on a phone?A2: The 'Mobile End Address' setting in AnQiCMS backend merely stores this URL, it will not automatically perform a jump.If you want the mobile user to automatically redirect to the PC end when accessing, or vice versa, you need to add additional JavaScript code in the template to implement device judgment and redirection logic.You can also consider using an adaptive theme, so there is no need for a separate mobile end URL and jump mechanism.

Q3: Do I need to set a mobile URL if my website is responsive design?A3: If your website uses responsive design, this means that both the PC and mobile ends use the same URL and a set of code, automatically adapting to different screen sizes through CSS or other technologies, so you usually do not need to set a separate 'mobile end address'.In this case, your website URL is suitable for both PC and mobile devices.This 'Mobile Address' feature is mainly used for websites in the 'PC+Mobile Independent Site Mode'.

Related articles

How to use AnQiCMS filters to truncate or convert text to uppercase and lowercase?

AnQiCMS provides powerful flexibility in content display, its template engine is built-in with a rich set of filters, helping users to easily process text without modifying the original content, including truncation and case conversion.These filters make the presentation of front-end content more accurate and beautiful, meeting the display needs of different scenarios.In AnQiCMS template syntax, the use of filters is very intuitive.You can apply a filter by adding a pipe symbol (`|`) after the variable name, if the filter requires parameters, then use a colon (`:`) after the filter name

2025-11-08

How to use a for loop to traverse data and display it in the AnQiCMS template?

AnQiCMS with its flexible and powerful template system makes content display efficient and expressive.For website operators and developers, mastering how to traverse and display data in templates is a key step to unlocking their powerful features and bringing the website content to life.Today, let's delve into how to use the `for` loop in AnQiCMS templates to easily present your dynamic data.AnQiCMS's template engine adopts syntax similar to Django, which allows users familiar with other mainstream template languages to quickly get started.

2025-11-08

How to implement conditional judgment in AnQiCMS template to control the display of content?

In AnQi CMS template design, flexibly controlling the display of content is the key to building dynamic, responsive websites.Whether it is to display different information based on page type, data status, or specific conditions, conditional judgment is an indispensable tool.The AnQiCMS template engine provides an intuitive and powerful conditional judgment mechanism, allowing you to easily implement these complex logic.### Core Grammar: The Basics of Conditionals The condition judgment in AnQiCMS templates is similar to many mainstream template engines, using the `{% if ... %}` tag structure

2025-11-08

How to format a timestamp and display it as a readable date and time in AnQiCMS?

In website content operation, time information plays an indispensable role.Whether it is the publication time of the article, the shelf date of the product, or the submission time of the comments, a clear and readable date and time format can greatly enhance the user experience.AnQi CMS as an efficient content management system, fully considers this point, and provides a flexible way to format and display these timestamp data.### Understanding Timestamps in AnQi CMS In the AnQi CMS backend, when we publish articles, products, or perform other content management operations

2025-11-08

How to display the path of static files (CSS/JS/images) in AnQiCMS template?

When building a website with AnQiCMS, the correct reference to static files (such as CSS stylesheets, JavaScript scripts, and images) is the basis for ensuring the normal operation and beautiful presentation of the website.AnQiCMS provides us with a clear and flexible mechanism for managing and displaying these file paths, whether it is the static resources built into the template or the media files uploaded through the backend, there is a convenient way to reference them.

2025-11-08

How to implement multi-language content switching and display in AnQiCMS?

Today, having a website that supports multiple languages has become a key factor for enterprises to expand into international markets and enhance user experience.AnQiCMS is an efficient and flexible content management system that fully considers this need, providing you with a convenient multi-language content switching and display solution. Different from simply stacking multiple languages on the same page, AnQiCMS adopts a more flexible and powerful multi-site management mode to achieve multilingual support.

2025-11-08

How does AnQiCMS control the display and hiding of content based on user group permissions?

When building and operating a website, we often encounter such needs: some content is intended for everyone to see, while others are designed specifically for certain user groups, such as paid membership exclusive, VIP content, or materials for internal team review.AnQiCMS provides a powerful and flexible user group permission control mechanism that can help us easily achieve fine-grained display and hide of content.

2025-11-08

How to display data of custom content models (such as products, events) in AnQiCMS?

Manage and display custom content models in Anqi CMS, such as product lists, event details, etc., which is a reflection of its powerful flexibility.The design philosophy of AnQi CMS aims to allow users to highly customize the content structure according to their own business needs and present these structured data in a直观, rich manner on the website front-end. ### The Foundation of Flexible Content Models Firstly, we need to understand the "Flexible Content Model" feature of Anqi CMS. It allows you to go beyond the traditional 'article' category, creating content types with unique fields. For example

2025-11-08