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.