How to get the list of all configured multilingual sites in AnQiCMS?

Calendar 👁️ 72

As an experienced website operation expert, I fully understand how important it is for a company to have a website that supports multiple languages in today's global digital world to expand its market and enhance its brand influence.AnQiCMS (AnQi CMS) is an efficient and flexible content management system that provides excellent support in this regard.It can not only help us build multiple independent sites, but also allow these sites to easily switch between different languages to meet the needs of global users.

Today, let's delve into how AnQiCMS elegantly retrieves the list of all configured multilingual sites, which is crucial for implementing website internationalization and providing a seamless user experience.

The concept of 'Multi-language site' of AnQiCMS

In AnQiCMS, the implementation of multilingual is usually based on its powerful multi-site management function.This means you can configure an independent site for each language (or a logically distinct sub-site), each with its own content, templates, and language settings.The advantage of this architecture lies in its great flexibility, which allows content management and localization strategies to be very fine-grained.

The system-level "default language package support" ensures the multilingualization of the background operation interface, while the multilingual display of the front-end page depends on the language sites you configure and the corresponding calls in the template. To implement a fully functional multilingual website, obtaining the list of these sites is essential for building the language switcher, SEO optimization (such ashreflangLabel) and the first step.

Core function:languagesLabel revelation

In the powerful template label system of AnQiCMS, there is a label specially tailored for multilingual site management, which is ——languagesThis tag helps us easily obtain the list of all configured multilingual sites and display this information on the frontend.

When we uselanguagesWhen a tag is encountered, it returns an array object containing all the configured multi-language site information. Each site information includes rich details such as the name of the site's language (LanguageName)Language code(Language) Rich language emojis (LanguageEmoji) and icons (LanguageIcon) and of course, the most important site link (Link) and the name of the site itself (Name)such data is sufficient to support us in building various complex language switching and SEO strategies.

How to use?

languagesThe usage of the tag is very intuitive, itNo additional parameters are required,You only need to open a tag block like this in the AnQiCMS template file:

{% languages websites %}
    {# 循环输出每个站点信息 #}
    {% for item in websites %}
        {# 在这里使用 item 变量访问站点数据 #}
        {{ item.LanguageName }} - {{ item.Link }}
    {% endfor %}
{% endlanguages %}

Here, websitesIs the variable name you define for the site list data you get. You can name it according to your habit.itemIt isforA variable representing each individual site information in the loop.

Practical application: two typical scenarios

MasteredlanguagesAfter the label, we can apply it to the actual website operation, and the following are the two most common application scenarios.

1. Build Language Switcher (Language Switcher)

A straightforward language switcher can significantly enhance user experience, allowing visitors to choose the website language according to their preferences. By utilizinglanguagestags, we can easily achieve this.

Assuming we want to display a language switch dropdown menu at the top of the website header, so that users can click on it to jump to the corresponding language site.

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

In this code block:

  • We first pass through{% languages websites %}Get the list of all multilingual sites and store it inwebsitesthe variable.
  • {% if websites %}Ensure that the switcher is rendered only when there are multilingual sites, to avoid empty blocks on the page.
  • {% for item in websites %}Iterate through each site's information.
  • item.LinkProvided the URL of the current language site for easy user click-through.
  • item.LanguageIconoritem.LanguageEmojiCan display a concrete language identifier to enhance visual effects.
  • item.LanguageNameThen it shows the name of the language clearly.

With this code, you can elegantly display a language selector in the header, footer, or sidebar of a website, allowing users to easily switch to the language version they want.

2. Implement Hreflang Tag (SEO Optimization)

For SEO optimization of multilingual websites,hreflangLabels are indispensable.It tells the search engine which language versions your page has, thus ensuring that the correct language and regional content is displayed to users.This is crucial for avoiding duplicate content penalties and improving international SEO performance.languagesTags can be very convenient to help us dynamically generate these tags.

You need to place the following code in your website template.<head>In the area, for example, inpartial/header.html(If you follow the AnQiCMS template structure):

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

In this code block:

  • We also go through{% languages websites %}Get the list of sites.
  • item.LinkUsed to specify the URL of the corresponding language page.
  • item.LanguageIt provides language codes in ISO 639-1 format (for exampleenrepresenting Englishzh-CNrepresenting Simplified Chinese), this ishreflanga key attribute of the tag.

This way, each language version of your page will automatically include links to all corresponding language versionshreflangThis greatly enhances the international SEO capabilities of the website.

Deep understanding: Characteristics and precautions of tags

  • No parameters required, globally retrieved: languagesThe simplicity of the tag is that it does not accept any parameters.This means it will retrieve the list of all multilingual sites configured in the AnQiCMS system.foruse labels insideifJudgment under conditions.
  • Return array object:UnderstandingwebsitesA variable is crucial for an array, therefore it must be used in conjunctionforto iterate over each site object.
  • with rich data fields:Each site object provides detailed information including links, names, language codes, and icons, which greatly facilitates front-end development.

BylanguagesLabel, AnQiCMS makes the management of multilingual sites and front-end display simpler and more efficient than ever.As a website operator, fully utilizing this feature will enable you to better serve global users and optimize your international content strategy.


Frequently Asked Questions (FAQ)

Q1:languagesDoes the tag support filtering, such as only getting lists of English and French websites?A1:languagesThe tag itself does not provide filtering parameters, it will retrieve the list of all configured multilingual site lists. If you need to filter, you can do so after obtaining the completewebsitesarray, in{% for %}use labels inside{% if %}conditions to judge.item.Languageoritem.LanguageNameThus, only the language sites you need will be displayed. For example:{% if item.Language == 'en' or item.Language == 'fr' %}.

Q2: What information does the list of site data obtained contain?A2: Where each site isforthrough the loopitemThe variable exposed multiple data, including but not limited to: the language name of the site (LanguageName)Language code(Language), language emoji (LanguageEmoji), language icon (`Language

Related articles

Can AnQiCMS's Json-LD combine `nextArchive` and `prevArchive` tags to generate structured data for related articles?

As an experienced website operations expert, I know that structured data plays a crucial role in modern search engine optimization.It can help search engines understand web content more accurately, thus giving them the opportunity to display richer search results (Rich Snippets), attracting more users to click.AnQiCMS (AnQiCMS) is an enterprise-level content management system that attaches great importance to SEO and naturally provides strong support and flexible customization space in this regard.

2025-11-06

Can Json-LD directly reference the image resource address of AnQiCMS, such as the thumbnail URL?

## Empowering Structured Data: Direct Reference Strategy for Anqi CMS Image Resources in Json-LD As an experienced website operations expert, I am well aware of the importance of structured data (Structured Data) in today's search engine optimization (SEO) field, which is self-evident.It not only helps search engines better understand page content, but is also the key to obtaining rich search results (Rich Snippets).While Json-LD is the mainstream implementation of structured data, its accuracy and completeness directly affect the exposure and click-through rate of a website

2025-11-06

How to debug Json-LD output in AnQiCMS template?

In the operation practice of AnQiCMS (AnQiCMS), structured data (usually presented in the form of Json-LD) plays a crucial role.It can help search engines better understand the content of the page, thus potentially obtaining rich search results (Rich Snippets), significantly improving the visibility and click-through rate of the website.

2025-11-06

Does Json-LD automatically add `itemprop` and other microdata tags, or only support JSON-LD?

As an experienced website operations expert, I am happy to give you a detailed explanation of AnQiCMS's support strategy for structured data, especially JSON-LD and traditional microdata tags.In today's Search Engine Optimization (SEO) environment, structured data plays a crucial role, helping search engines to accurately understand your web page content, thereby improving the visibility and display format of your website in search results.### The structured data support of AnQi CMS: Deep analysis of JSON-LD and microdata tags In content operation practice

2025-11-06

How to use the `languages` tag in AnQiCMS templates to display language options?

In today's globalized digital world, multilingual support for websites has become crucial for expanding markets and serving a diverse range of user groups.AnQiCMS (AnQiCMS) is well-versed in this field, deeply integrating multilingual functionality into its core architecture, committed to providing lightweight and efficient content management services to support the company's global layout.For website operators and template developers, understanding how to efficiently use the `languages` tag in AnQiCMS templates to display multilingual options is a required course for building internationalized websites.###

2025-11-06

What are the available return fields supported by the AnQiCMS multilingual site list tag?

In the powerful feature matrix of AnQiCMS (AnQiCMS), multi-language support is undoubtedly one of its highlights, helping businesses easily expand into the international market and bringing content directly to global users.In order to achieve this goal, it is crucial to flexibly use template tags.Today, let's delve into the `languages` tag used in AnQiCMS to retrieve the list of multilingual sites, see what valuable fields it can return to us, and how we can skillfully use these fields to build an excellent multilingual website.### Revealing the `languages` tag

2025-11-06

How to use the `languages` tag to build a multi-language switch menu on the page?

AnQi CMS is committed to providing enterprises with efficient and flexible content management solutions, one of the core highlights being its powerful multilingual support capabilities.In today's globalized world, a website that can easily handle multilingual content undoubtedly provides strong support for a company to expand its international market and reach a wider user base.Today, let's delve into how Anqi CMS cleverly uses the `languages` tag to build a natural and smooth multilingual menu on your website, thereby opening a new chapter in global content marketing.

2025-11-06

Does the `languages` tag in AnQiCMS support any parameter settings?

AnQi CMS, as an enterprise-level content management system, has an excellent performance in helping enterprises to carry out global content layout, among which 'multilingual support' is one of its core advantages.When developing templates for AnQiCMS, we often encounter the need to display or switch the website language, which is when a key template tag - `languages` - comes into play.### Core Functionality and Design Philosophy of `languages` Tag in AnQiCMS Directly answer the most concerned questions of everyone

2025-11-06