In the ecosystem of AnQi CMS, multilingual support and multi-site management are its core advantages, aiming to help businesses and content operators easily expand into the global market.When you build a multilingual site and want to provide a language switch function on the front endThe answer is affirmative, and this design has brought great convenience and rationality in practical application.
Understand the multilingual site list mechanism of AnQiCMS
AnQiCMS handles multilingual site lists in a very intuitive and easy-to-use manner. It provides a special template tag -languagesUsed to dynamically retrieve all configured multilingual site information in your website template.The design of this label was originally to facilitate website visitors in switching between different language versions.
Specifically, when you use{% languages websites %}...{% endLanguages %}This template structure is used to call the list of multilingual sites, AnQiCMS will return an array object containing all the multilingual sites that have been set (here it is named as the followingwebsites)。It is worth noting that thislanguagesThe tag does not accept any parameters. This means that regardless of which language version of the site the user is visiting, it will list all available multilingual sites without discrimination, including the site the user is currently browsing.
What information is included in the multilingual list item?
Each inwebsitesthe item in the array of sites (we usually refer to it in theforloop as itemAll carry rich metadata, enough to build a fully functional language switcher. This information includes:
- Site language name (
LanguageName)For example "Chinese", "English". - Language code (
Language): Standard ISO language codes such aszh-CN/en-US, which is crucial for generatinghreflangtags, which is helpful for SEO. - Language emoticon (
LanguageEmoji): Such as 🇺🇸, 🇨🇳, it can add visual fun to the language switch button. - Language icon (
LanguageIcon): If a custom language icon is configured, the link will be provided here. - Site name (
Name): The specific name of the language site. - Link address (
Link)One of the most important pieces of information, it provides the complete URL to jump to the language site. - Note (
Remark)andNofollow (Nofollow)These provide some additional information and SEO control options.
These fields aggregate, allowing you to flexibly display language switch options on the front end, whether it is text links, icons with buttons, or combininghreflangLabeling for search engine optimization can be easily achieved.
Why is the current site information included in the list?
The reason why AnQiCMS includes the information of the current visited site in the multilingual list is mainly based on the following considerations:
- The integrity of user experience:The purpose of language switching is to allow users to see all available language options.If the current language version is not listed here, it may confuse the user, making it difficult for them to intuitively know which language version they are in and also unable to choose to reload the page in the current language.
- Simplicity of code implementation:
languagesLabel design without parameters simplifies the logic for template developers.It uniformly returns all data, developers do not need to write additional judgment logic to exclude the current site, just display or add special styles as needed in the template. - SEO optimization:AnQiCMS supports generating multilingual lists through
hreflangtags. In HTML,<head>The placement of these tags can clearly inform search engines of the corresponding relationship between different language versions of pages, which is crucial for the SEO performance of international websites.hreflangThe specification of the label requires it to include the current page itselfhreflangTherefore, including the current site in the list is in line with this standard.
In short, the design of AnQiCMS is well thought out, providing rich information while also considering ease of development, smooth user experience, and the SEO requirements of international websites.
The difference with getting the current site information
It is worth mentioning,languagesThe tag provides a list of "all multilingual sites". If you just want to get the current site you are accessingitselfSystem information (such as website name, Logo, base URL, etc.), AnQiCMS provides another namedsystemtag. Through{% system with name="SiteName" %}This way, you can directly access the specific properties of the current site without having to traverse the entire multilingual site list.These tags perform their respective duties, together forming AnQiCMS's powerful and flexible content management system.
Frequently Asked Questions (FAQ)
Ask: AnQiCMS multi-language site list tag (
languages) Can it filter out the current site and only display other language options? Answer:languagesThe tag itself does not provide parameters to directly filter the current site. It returns all configured multilingual site information, including the current visited site.If you need to hide the current language option on the frontend interface or add a special style to the current language option, you can use it in the template byifConditional judgment, based onitem.LinkCompare it with the current page URL to manually implement.Question: How can you ensure that the page URL jumps to the correct language version of the current page content when switching languages? Answer:
languagesEach item returned by the tag contains oneLinkfield (item.LinkThis link address is the base URL of the language version site.AnQiCMS will automatically generate the correct redirection link based on your multilingual configuration and the current page path.For example, if the current is/article/1After switching to the English site, it usually also tries to jump to/en/article/1or similar structure, to ensure that users remain in the same content context when switching languages. In addition, combininghreflangThe use of tags also helps search engines understand the correlation between different language versions of the content.Question:
languagesThe list of tags obtained by the site, does it include those ordinary sites that have not configured multilingual functions? Answer:languagesThe tag is designed to retrieve the list of 'Multilingual Sites'. According to the AnQiCMS documentation, it returns information about all sites that have configured multilingual properties.This means that sites that run independently but are not explicitly configured as part of a multilingual setup are usually not included in this list.