How to configure multilingual content switching in AnQiCMS to support browsing by users from different countries?

Today, with the deepening of globalization, enabling your website to support multiple languages and reach users in different countries is a key step in expanding the market and enhancing brand influence.AnQiCMS (AnQi CMS) fully considered this requirement at the initial design, providing users with an efficient and flexible multilingual content switching solution.

The core of AnQiCMS achieving multi-language content switching lies in its powerfulMulti-site managementfunction, supplemented byDefault language packageconfiguration, as well as the frontendTemplate TagThe flexible application. It effectively distinguishes the language display at the system level from the language management of actual content (articles, products, etc.), ensuring the independence of content and the convenience of management.

Understanding AnQiCMS's multilingual architecture

AnQiCMS mainly adopts the strategy of "site isolation, unified management" in multilingual support.This means that if your website needs to provide completely different content for different languages, or needs to have independent domains and SEO strategies for each language version, then creating multiple language sites is the recommended and efficient way by AnQiCMS.Each site can be considered an independent language version, with its own content, categories, and templates.

At the same time, AnQiCMS also provides the option for the "default language package".This is mainly used to change some built-in prompt information, background interface language, etc.For example, you can choose to set the background interface to Chinese or English.However, it should be noted that the language package settings will not automatically translate the specific content of your website articles, product descriptions, and other content. This content needs to be created and managed independently for each language site.

Configuring a multilingual site: content isolation and unified management

To truly implement multilingual content switching, you need to make full use of the multi-site management function of AnQiCMS.This is like setting up branches of your brand in different regions of the world, with each branch responsible for content operations in a language market.

  1. Add a new site:In the AnQiCMS backend, find the 'Multi-site Management' feature, click 'Add New Site'. Here, you will create a separate site for each language version.
  2. Set critical information:
    • Website address:This is the most important link in your multilingual strategy. You can set independent subdomains for different language sites (such asen.yourdomain.comRepresents the English site) or distinguished by subdirectories (such asyourdomain.com/enRepresents the English site). Ensure that each language version has a clear and unique access address.
    • Site root directory and database name:To ensure the independent storage and management of content for different language versions, you need to specify a unique "site root directory" and "database name" for each language site.AnQiCMS will store the cache, uploaded files, and other data of the site in the specified directory, and store all the content data of the site in the specified database.This isolation design greatly reduces the complexity of multilingual content management and avoids data confusion.
    • Select the template to use:AnQiCMS allows you to select different templates for each language site.This means that you can design or use different interface layouts and styles for different language versions based on the cultural habits and aesthetic preferences of the target users.For example, English sites can use a minimalist modern style, while Japanese sites may tend to be delicate and intricate.
    • Admin account password:Set up independent administrator accounts and passwords for each language site, which can facilitate content management for different teams or individuals, and achieve separation of duties.

In this way, each language site has independent content publishing, classification management, and file resources.This lays a solid foundation for the creation and refined operation of subsequent language versions.

Implement front-end multilingual switching: guide users to the correct content

After you have configured multiple language sites in the background, the next step is to provide a convenient language switching entry on the website front end and guide search engines to correctly identify the content of these different language versions. AnQiCMS provideslanguagesTemplate tags to achieve this goal.

UselanguagesTag to create a language switcher

languagesTag can retrieve all the multi-language site information configured and display it as a switch link on the front end.

For example, you can add a language switcher at the top or bottom of the website header, the code is roughly as follows:

{%- languages websites %}
{%- if websites %}
<div class="language-switcher">
    <span>切换语言:</span>
    {%- for item in websites %}
    <a href="{{item.Link}}">
        {%- if item.LanguageIcon %}
        <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}}"/>
        {%- else %}
        {{item.LanguageEmoji}}
        {% endif %}
        {{item.LanguageName}}
    </a>
    {%- endfor %}
</div>
{%- endif %}
{%- endLanguages %}

In this code block,websitesThe variable contains detailed information about each language site, for example:item.LinkThis is the access address for the language version,item.LanguageNameThis is the language name,item.LanguageEmojianditem.LanguageIconIt provides a variety of language identification options. By looping through this information, you can easily build a beautiful and practical language switch menu.

Optimize SEO: The use of Hreflang tags

To avoid search engines treating different language versions as duplicate content and to ensure that users are directed to the version most suitable for them, usehreflangTags are crucial. AnQiCMS'languagesTags also provide convenience for this. You can use tags in the website's HTML pages.<head>Add in the blockhreflangTags can guide search engines:

{%- languages websites %}
{%- for item in websites %}
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
{%- endfor %}
{%- endLanguages %}

This code will generate a label for each language sitelink rel="alternate"wherehrefpointing to the URL of this language version,hreflangthen specifies the language code of the page (such asenrepresenting Englishzh-CNRepresenting Simplified Chinese). This effectively helps search engines understand the structure of your multilingual content, thus improving the search visibility of all language versions.

Content creation and optimization: Ensure quality of multilingual content

Once the multilingual site architecture is completed and the front-end switch entry is set, the focus will be on the content itself.Each language site needs to fill in high-quality, native language content.

  • Independent TDK settings:For each language