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

Calendar 👁️ 57

AnQiCMS plays an important role in global content promotion, and its multilingual content switching and display features can help your website easily meet the needs of users from different language backgrounds.This not only expands your potential market, but also optimizes the browsing experience of users in different regions.

To implement multilingual content display in AnQiCMS, we first need to understand its core design philosophy: multilingual sites are usually considered as independent "sites" for management.This means that if you need a Chinese version of a website and an English version, they may be configured as two independent sites internally in AnQiCMS, but they can share the same AnQiCMS instance for centralized management.

The foundation for building multilingual content: site and content management

First, AnQiCMS provides "default language package support", you can set a default language for your website in the global settings of the background.This setting mainly affects the built-in text display of the system, such as the background interface or some general prompt information.However, to truly implement language switching for front-end content, you need to create and maintain corresponding content for each target language.

This means that if you have a product page, such as "Product A", to support Chinese and English, you need to create "Product A (Chinese)" under the Chinese site and "Product A (English)" under the English site.The multi-site management feature of AnQiCMS provides convenience, allowing you to easily switch and manage content of different language sites under the same AnQiCMS platform.When you post documents, create categories, or single pages on a site in a specific language, all content will be edited and stored in the language of that site.

Language switch and display in the template

AnQiCMS's template engine is designed flexibly, allowing you to implement fine-grained language control on the front-end page.There are mainly two ways to handle multilingual display: one is to translate the fixed text in the template, and the other is to provide a multilingual site switching entry.

For fixed text in the template like "Your location", "Home page", you can usetrTranslate tags. Its working principle is to create alocalesfolder under the template root directory, and establish independent subfolders for each language (such aszh-cn/en-us),each subfolder contains onedefault.ymlfile. In this YML file, you will associate the original text with the corresponding translation text in the form of key-value pairs. For example,"yourLocation": "您的位置". Used in the template{% tr "yourLocation" %}The system will automatically display the corresponding translated text based on the current site language setting.

To allow users to easily switch language versions on the website,languagesTags are indispensable. Through this tag, you can get a list of all multilingual sites that have been configured.In the template, you can iterate over this list to generate a withLink(site link),LanguageName(language name) andLanguageIcon(language icon) and other information toggle buttons or dropdown menus. For example:

{% languages websites %}
  {% if websites %}
    <div>
      <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 %}

This code snippet can dynamically generate a language selector that allows users to click and jump to the corresponding language version of the website.

Optimize the multilingual crawling of search engines

In multilingual website operation, Search Engine Optimization (SEO) is crucial. To avoid duplicate content penalties and ensure that search engines correctly identify your multilingual pages, usehreflangTags are a standard practice. AnQiCMS also passes throughlanguagesTags provide conveniencehreflangImplementation. You can access the website's<head>In the block, using loop-generated site data, add for each language version<link rel="alternate" href="..." hreflang="..." />Tags:

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

This tells search engines that your website has multiple language versions, and specifies the URL and corresponding language for each version, which helps search engines guide users to the most suitable page for their language and region.

In short, AnQiCMS integrates multilingual capabilities into its multi-site management framework and combines flexible template tags to provide a comprehensive and easy-to-operate multilingual content solution for the website.The content organization from the backend to the frontend interface display and search engine optimization has received thorough support, helping your website to spread efficiently worldwide.


Frequently Asked Questions (FAQ)

Q1: Does creating a multilingual site in AnQiCMS mean that multiple independent databases need to be created?

A1: AnQiCMS's multi-site management shares the same database instance by default.When you create a new site, you can choose to "re-use the default database account information", and the system will create an independent table in the same database to store the content of the new site, in order to achieve data isolation and management.Therefore, it is usually not necessary to set up a separate database for each language site.

Q2: How is the process for adding a new language to my website?

A2: First, you need to create a new site in the AnQiCMS backend through the "Multi-site Management" feature, specify the corresponding domain and administrator information for it, and usually also select a default language for the new site.Then, you need to manually translate and publish the content for the new language.On the template level, you canlocalesCreate a new language in the catalog.default.ymlFile, and add the corresponding translation content. Finally, make sure that your language switcher (usinglanguagestag construction) can recognize and link to this newly created language site.

Q3: Does AnQiCMS support internal association between different language versions of the same article for quick switching and viewing?

A3: The design concept of AnQiCMS is to treat different language versions as independent "sites" for content management.This means that, in the background, the Chinese and English versions of the same article are treated as two separate documents, stored on their respective language sites.The system itself does not provide a built-in "association" feature to automatically link different language versions of the same article.If you need such an association, you may need to implement custom logic at the template level, such as setting a common "Content ID" field for each piece of content, then obtaining the common ID of the current content through template tags, and combininglanguagesThe link obtained from the other language sites, building a jump link to the corresponding language version. This requires certain knowledge of template development and content management standards.

Related articles

How to efficiently display multi-site content in Anqi CMS?

In today's complex digital environment, many enterprises and content creators no longer satisfy with single-site operations.Brand expansion, regional coverage, and product line segmentation often require multiple independent websites to carry different content and marketing strategies.How can one maintain the independence of content across various sites while also efficiently managing and displaying it uniformly, which is a challenge faced by many operators.AnQi CMS, with its specially designed ability for multi-site management, provides us with an elegant solution.###

2025-11-08

How does AnQiCMS generate structured data through Json-LD tags to optimize the display results of search engines?

In today's highly competitive online environment, it is more important than ever to make your website content stand out in search engines.Relying solely on keyword stuffing and traditional SEO methods is no longer enough to achieve **results.Structured data, especially structured data implemented through Json-LD format, is becoming a key factor in improving search engine display results and attracting more target users' attention.AnQiCMS (AnQiCMS) knows this and provides powerful and flexible features to help you easily master this technology.### Structured Data

2025-11-08

How to define temporary variables or use macro functions to organize complex display logic in templates?

When using Anqicms to manage website content, we often encounter scenarios where we need to display complex data or reuse similar layouts.If the display logic in the template is not organized effectively, it will soon become long and difficult to read, and it will also be particularly difficult to maintain.Luckyly, Anqi CMS's template engine (which supports Django template engine syntax) provides powerful tools such as defining temporary variables and using macro functions, which can help us elegantly solve these problems, making the template code clear and efficient.Why do we need more flexible template logic

2025-11-08

How to process and display variable content through filters (such as `truncatechars`, `safe`)?

## Optimize Content Display: Application of Variable Filters in AnQi CMS How to present information accurately and beautifully in website content management is the key to improving user experience.AnQi CMS is a flexible and efficient content management system that provides a powerful template engine, allowing us to refine and display variable content through various filters, thereby better meeting the needs of page layout and information delivery.These filters are like the 'makeup artists' of content, allowing the original data to be displayed in the most appropriate form.The AnQi CMS template engine uses syntax similar to Django

2025-11-08

How does the static settings affect the search engine display effect of the website URL?

The website's URL address, which is also known as the 'website address', is the first window for users and search engines to understand the content of the website.A clear and meaningful URL not only enhances user experience but is also an indispensable aspect of search engine optimization (SEO).AnQiCMS (AnQiCMS) provides powerful pseudostatic settings for URL optimization, which has a direct and profound impact on the display effect of the website URL in search engines.What is the concept of pseudo-static and why is it important? Before delving into the impact, let's first understand what pseudo-static is

2025-11-08

How to ensure the visibility and content display of the website in search engines?

In today's highly competitive online environment, it is the core concern of each operator to ensure that the website has visibility in search engines and displays content efficiently.A comprehensive content management system (CMS) is the key to achieving this goal.AnQiCMS is a system designed specifically for small and medium-sized enterprises and content operation teams, providing many powerful functions to help us achieve these goals more effectively.--- ## AnQiCMS: Ensuring website visibility and content display in search engines The visibility of a website determines whether it can be discovered by potential users

2025-11-08

How to add watermarks to images to protect the display rights of original content?

In the era of internet content explosion, the originality of images and copyright protection are particularly important.Well-crafted image materials are an indispensable part of website content, as they not only enhance the user experience but also reflect the brand image of the website.However, the phenomenon of unauthorized image theft is common, which not only harms the original creators' labor results but may also blur the source of the content.AnQi CMS understands this, therefore its system is built with powerful image watermarking functions, aimed at helping users effectively protect the display rights of original images, ensuring that your visual content can be clearly marked with your exclusive imprint.###

2025-11-08

How to set up a specific user group to view paid content?

In website operations, converting high-quality content into cash is a common need, and restricting specific user groups to view paid content is the core strategy to achieve this goal.AnQiCMS (AnQiCMS) fully understands this need, therefore, it has built a powerful user group management and VIP system to make content monetization simple and efficient.Below, we will discuss how to set up a specific user group to view paid content in Anqi CMS, which will help you better utilize this feature.### Understanding AnQi CMS User Groups and Permission System AnQi CMS provides a comprehensive user group management mechanism

2025-11-08