How to set up and display the multi-language switch link in AnQiCMS?

Calendar 👁️ 87

Today, with the increasing trend of globalization, website multilingual support has become crucial for expanding international markets and serving diverse user groups.AnQiCMS fully considered this requirement, providing flexible multi-language settings and switching functions, allowing the website to easily provide localized content experiences for users of different languages.This article will introduce in detail how to set and display the multi-language switch link in AnQiCMS, and discuss the relevant practical strategies.


1. Understand the multilingual mechanism of AnQiCMS

In AnQiCMS, the multilingual feature is usually closely integrated with multi-site management.This means that if your website needs to provide completely independent, content-wise different multilingual versions, the most common and recommended approach is to set up a separate site for each language.One of AnQiCMS's core strengths is that it supports "multi-site management", allowing you to easily create and maintain multiple language sites within a single system.Each site can have its own domain (or subdomain/subdirectory), independent language packs, and corresponding language content.

When you need to provide 'language switch links' on the website front-end, these links actually guide users to access your different language versions of the site.

Second, backend configuration: lay the foundation for a multilingual website

To implement language switching, you first need to make the corresponding settings in the background. This mainly involves two aspects: the setting of the system language package, and the creation of multilingual sites.

  1. Set default language package (for backend interface and system prompts)Log in to the AnQiCMS backend, find "Backend Settings" in the left navigation bar, and click "Global Settings".Here, you will see the "Default Language Pack" option. You can choose "Chinese", "English", or any other supported language.This setting mainly affects the language of the AnQiCMS backend management interface and the system-generated prompts on the website.It does not automatically translate the articles, products, and other dynamic content you post.

  2. Create multilingual site (for frontend content)This is the key step to implement front-end multilingual content display and switching.If you need an independent English website to display English content, you need to create a new site in the "Multi-site Management" section of the AnQiCMS backend.

    • Find "Multi-site Management" in the left menu of the background, and then click "Add New Site".
    • Create a page on the new site, you can fill in items such as "Site Name" (such as: AnQiCMS English Site), "Root Directory of Site", "Website Address" (such as:en.yourdomain.comorwww.yourdomain.com/en/)等信息。
    • It is important that you can choose a different "default language package" for this new site and configure its independent database (or reuse the main site's database but use a different table prefix to achieve data isolation).
    • After completing the site creation, you will have an independent English version of the site where you can publish exclusive English articles, products, and more.For other language versions, create them in this manner.

In this way, you create a logically independent space for each language, which can be accessed through independent domains or paths and carries the content of each language.

Chapter 3: Front-end Display: How to Display Multi-language Switch Links

Once the multilingual site structure is set up on the back end, the next step is to add multilingual switch links to the front-end templates. AnQiCMS provides a very convenient template tag.languagesTo implement this.

  1. UselanguagesTag to get the language site list

    languagesTag can get all the multi-language site information configured. You can do this in the public part of the website, such as the header (header.html) or the footer (footer.html),use this tag to generate a language switcher.

    {%- languages websites %}
    {%- if websites %}
    <div class="language-switcher">
        <span>切换语言:</span>
        {%- for item in websites %}
        <a href="{{item.Link}}" class="lang-item">
            {%- if item.LanguageIcon %} {# 如果后台配置了语言图标,则显示图标 #}
            <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}} Flag" class="lang-flag" />
            {%- else %} {# 否则显示 Emoji 或语言名称 #}
            {{item.LanguageEmoji}} {# 显示语言的 Emoji 符号,如 🇨🇳 #}
            {% endif %}
            {{item.LanguageName}} {# 显示语言名称,如 中文 #}
        </a>
        {%- endfor %}
    </div>
    {%- endif %}
    {%- endlanguages %}
    
    • websitesIt is an array object that contains details of each language site.
    • item.LinkThis is the most important attribute, which will generate the complete URL pointing to the language site.
    • item.LanguageNameThe display name of the language (such as 'Chinese', 'English').
    • item.LanguageEmoji: Language corresponding emoji symbols (such as 🇨🇳, 🇬🇧), which can enhance the visual effect.
    • item.LanguageIconIf the background is configured with a language icon, the icon URL will be output here.

    This code will iterate through all the configured language sites and generate a link for each site, which the user can click to jump to the corresponding language version website.

  2. Configure Hreflang tag for SEO optimization

    In order to better guide search engines to understand the different language versions of your website and display them to the correct users, it is recommended that you add the site's<head>Partially addhreflangTag. This is crucial for improving international SEO.

    You can place the following code in your template file (usually)bash.htmlorheader.html)的<head>Area:

    {%- languages websites %}
    {%- for item in websites %}
    <link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
    {%- endfor %}
    {%- endlanguages %}
    
    • hreflang="{{item.Language}}"It will output the correct language code (such aszh-cn/enHelp search engines distinguish different language pages.

Chapter 4: Content translation: Beyond the interface level of multilingualism.

AlthoughlanguagesThe label provides links between sites, but the actual content translation still needs to be managed manually.

  1. The static strings in the translation template.For fixed text in templates, such as navigation menu items, copyright statements, "Contact Us" buttons, etc., you can use AnQiCMS'strThe translation label combines with the language package file to implement.

    • Create under the template directorylocalesfolder, and create a corresponding subfolder for each language (such aszh-cn/en-us)
    • Place in these subfoldersdefault.yml(Or another custom .yml file), and define key-value pairs, for example“yourLocation”: “您的位置”.
    • In the template, use{% tr "yourLocation" %}It can display the corresponding translation according to the current site language setting.
  2. Translate dynamic content (articles, products, etc.)For articles, products, and other dynamic content, you need to create and publish content independently for each language site.For example, publish Chinese articles under your Chinese site and then publish the corresponding English articles under the English site.AnQiCMS's multi-site management feature makes this content isolation and management very efficient.

V, some practical suggestions

  • Intuitive visual cues: Use national flags in the language switcher (viaLanguageIconor EmojiLanguageEmojiThe combination of language names with symbols can make users choose more intuitively.
  • Default language settingsMake sure new users or users who cannot identify the language can access the default language version of your website.
  • User ExperiencePlace the language switcher in a prominent location on the website, such as the top right corner of the header or the footer, making it easy for users to find.

By following these steps, you can set up and display multilingual switch links on the AnQiCMS website, effectively expand the international influence of the website, and provide a more friendly access experience for global users.


Frequently Asked Questions (FAQ)

Q1: Why did I set the "default language package" in the background, but the content of the articles on the website front-end is still in Chinese?**A1

Related articles

How to display breadcrumb navigation in AnQiCMS template to optimize user experience?

Have you ever felt lost while browsing a website?On an information-rich website, users sometimes feel overwhelmed, not knowing their current location, and it is also difficult to quickly backtrack to the upper page.This Breadcrumb Navigation is like a guiding light, providing clear path guidance and greatly optimizing their website experience.Breadcrumb navigation is usually displayed in the form of "Home > Category > Subcategory > Current Page", which can help users clearly understand their position in the website structure

2025-11-08

How to implement unified management of multi-site content and front-end display in AnQiCMS?

In the current complex and variable network environment, whether it is a large and medium-sized enterprise with multiple sub-brands and business lines, or a self-media operator that needs to create independent content platforms for different audience groups, how to efficiently manage multiple websites and ensure the flexibility and consistency of front-end content display has become a core challenge in content operation.The traditional 'one website, one system' model not only increases the cost of deployment and maintenance, but also makes content collaboration and data analysis extremely complicated.AnQiCMS (AnQi Content Management System) is precisely in such a context

2025-11-08

How to manage and display the list of friend links in AnQiCMS?

Friend links are an important part of website optimization and user experience, they can not only help your website rank better in search engines, but also provide visitors with more valuable resources, and also serve as a bridge to establish contact with industry partners.In AnQiCMS, managing and displaying friend links is a straightforward and flexible operation, allowing you to easily configure these important external connections for your website. ### Back-end Management Friend Links List To start managing friend links, you need to log in to the AnQiCMS back-end.All auxiliary functions are concentrated under the 'Function Management' menu

2025-11-08

How to retrieve and display single-page content in AnQiCMS, such as "About Us"?

In website operation, pages like "About Us" and "Contact Information" are indispensable components. They usually carry relatively fixed and important content such as corporate culture, contact information, and service introduction.For users of AnQiCMS, obtaining and displaying these single-page contents is not only simple and efficient but also highly flexible and customizable.This type of independent page, with content that does not change often, is classified as "single page" by Anqi CMS, and a dedicated management module is provided in the background for easy creation, editing, and publishing by users.

2025-11-08

How to configure the image watermark feature in AnQiCMS to protect the display of original content?

Today, with content creation becoming increasingly important, how to effectively protect the copyright of original images and prevent unauthorized use has become a focus for many website operators.AnQiCMS (AnQiCMS) fully understands this need, built-in image watermarking function, helps us easily add exclusive marks to images, thus effectively maintaining their exclusivity while displaying original content. Next, we will learn together how to configure the image watermark feature in AnQiCMS, adding a solid protective barrier to your visual content.###

2025-11-08

How does AnQiCMS automatically convert images to WebP format to speed up front-end loading?

In today's internet environment where content is exploding, the loading speed of a website is crucial for user experience and search engine rankings.Images are an important component of web content, and their loading performance is often a key factor affecting overall speed.AnQiCMS (AnQiCMS) understands this and provides the function of automatically converting images to WebP format, aimed at helping users effectively improve the front-end loading speed of websites.

2025-11-08

How to control the automatic compression of large images and the generation of thumbnails in AnQiCMS?

In website operation, images play a crucial role.They are not only elements that attract users' attention, but also directly affect the website's loading speed, user experience, and even the performance of search engine optimization (SEO).Managing website images, especially the compression of large-sized images and the generation of thumbnails, is a key link in improving website performance and aesthetics.AnQiCMS (AnQiCMS) fully understands this and provides flexible and powerful image processing features in its content management system, allowing you to easily control the automatic compression of large images and the generation of thumbnails.

2025-11-08

How to display custom contact information on AnQiCMS (such as WhatsApp, Facebook links)?

In today's digital age, a website is not just a platform for displaying information, but also an important bridge for businesses to connect with customers.Provide a variety of contact methods, such as WhatsApp, Facebook links, which can greatly enhance user experience and conversion efficiency.AnQiCMS as a powerful content management system provides a flexible and convenient solution in this regard.This article will introduce in detail how to set and display custom contact information in AnQiCMS, ensuring that your website can communicate with potential customers in the most convenient way.

2025-11-08