What is the type of the `websites` variable returned by the `languages` tag?

Calendar 👁️ 69

As an experienced website operations expert, I am well aware of the importance of multilingual support when building a global website. AnQiCMS (AnQi CMS) provides powerful and flexible functions in multilingual content management, among whichlanguagesThe label is the key to achieving this goal. Today, let's delve into it in detail.languagesthe tags returned bywebsitesVariable, what type is it, and how can we cleverly use it to build our multilingual site.

RevelationlanguagesTag: Bridge of multilingual sites

In AnQiCMS template development,languagesThe tag plays a crucial role in obtaining the list of all configured multilingual sites. Its usage is very concise and clear, usually defined as follows:{% languages websites %}As clearly indicated in the document, this tagdoes not accept any parametersThis means that no matter where you call it, it will reliably return all the multilingual site information you have set in the AnQiCMS backend, unbiased and comprehensive.

This design philosophy embodies the unity and convenience of AnQiCMS in multi-language functions.You do not need to pass complex parameters for different scenarios, just with one call, you can get an overview of the global multilingual configuration of the website.

websitesThe true form of a variable: an array object rich in structure

Then,languagesthe tag returns thewebsitesWhat is the specific type of this variable? The answer is:websitesIs aarray objectThis means it is not a simple string or number, but a collection of multiple elements, each representing an independent multilingual site configuration.

due towebsitesis an array, we need to use it in the templateforto iterate through it, so that we can access the details of each site one by one. Each item being iterated throughitemEach element carries the complete context information of a multilingual site, with a series of practical fields:

  • LanguageName(site language name)This is displayed to the user, usually the local name of the language, such as 'Chinese', 'English', etc., for the convenience of users to understand intuitively.
  • Language(Language code)A standardized language identifier, such as 'zh-cn', 'en-us'. It is used in constructing URLs, settinghreflangIt is crucial when communicating with search engines.
  • LanguageEmoji(Language Emoji): To enhance user experience, AnQiCMS allows the configuration of an Emoji expression for each language, such as China is 🇨🇳, and the UK is 🇬🇧.This plays a vital role in the language switcher.
  • LanguageIcon(Language Icon)If you prefer traditional flag icons or custom icons, you can configure the icon URL path here. WhenLanguageIconWhen present, the icon is usually displayed first, otherwise an Emoji is shown.
  • Name(Site Name): This is the name of the language site, which can beLanguageNameThe same can also be a more specific site brand name, such as 'AnQi CMS Chinese Site'.
  • Link(Link address)This is the complete URL pointing to the multilingual site. When the user clicks the language switch button, the link will guide them to the corresponding language version.
  • Remark(Note)A optional remark field, which can be used for internal management or to provide additional hints.
  • Nofollow(Whether nofollow)A boolean value (or 0/1) indicating whether the link should includerel="nofollow"Property. This is used in SEO strategy to control the transmission of link weight, especially for some non-core or links that do not want to pass weight.

Practical Application: Build Multilingual Switching and SEO Optimization

UnderstoodwebsitesAfter the structure of variables, we can show our skills in actual development.

1. Create a user-friendly multilingual switcher

A clear and intuitive language switch menu is an indispensable part of a multilingual website. Utilizewebsitesvariables, you can easily achieve this:

{%- languages websites %}
{%- if websites %} {# 仅当存在多语言站点时才显示切换器 #}
<div class="language-switcher">
    <span>切换语言:</span>
    {%- for item in websites %}
    <a href="{{item.Link}}" class="language-item">
        {%- if item.LanguageIcon %} {# 优先显示自定义图标 #}
        <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}}"/>
        {%- else %} {# 否则显示Emoji表情 #}
        {{item.LanguageEmoji}}
        {% endif %}
        {{item.LanguageName}}
    </a>
    {%- endfor %}
</div>
{%- endif %}
{%- endLanguages %}

This code first checks if there is a multilingual site, if there is, then it loops through each site's information and generates a toggle item for each site with a link, icon or Emoji and the language name.

2. Implement SEO-friendly Hreflang tags

For the SEO of multilingual websites,hreflangThe tag is to inform search engines that your page has other language or regional versions.Using it correctly can avoid duplicate content issues and ensure that search engines display content in the correct language to the target user.

You can place the following code snippet in the website template's<head>Area:

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

here,hreflangThe value of the attribute is used directlyitem.Languagefield, andhrefThe attribute points toitem.Link, perfectly achieving SEO standards. If your website also contains content for specific regions such aszh-hkRepresents the traditional Chinese language version for Hong Kong, this structure also supports it well.

Summary

AnQiCMS'languagesThe tag and the returned value.websitesAn array object, providing a clear, efficient, and powerful multilingual solution for website operators and developers. By understandingwebsitesis an array containing multiple site configurations as well as the objects contained in each siteLanguageName/Language/LinkThe keyword field allows us to easily build a user-friendly, SEO-optimized, and easy-to-maintain multilingual website.In today's global internet environment, mastering these functions will undoubtedly win more audiences for your website and expand a broader market.


Frequently Asked Questions (FAQ)

Q1:languagesCan the tag filter or specify the return of certain language sites?A1: Not allowed. As the document emphasizes,languagesThe tag does not accept any parameters, it always returns the list of all multilingual sites configured in the AnQiCMS backend. If you need to display only some languages on the front end, you need to get the completewebsitesAfter the array, in the template'sforthrough the loopifscreening conditions. For example, you can checkitem.Languagewhether it meets your display conditions.

Q2:LanguageEmojiandLanguageIconWhat are the differences, how should I choose to use it?A2:LanguageEmojiEmojis are displayed directly in the text without the need for additional image requests, usually load faster, but may not display consistently in some older browsers or operating systems.LanguageIconIs an image URL, it can be customized to be a national flag icon or any picture you like, making the display more uniform and more distinctive of the brand, but it will increase the cost of image loading. You can choose to use it according to the design style of the website, performance requirements, and compatibility with the target user's device, usually the template will try to display it first.LanguageIconIf empty, fallback toLanguageEmoji.

Q3:websitesIn variables,NofollowWhat is the purpose of the field?A3:NofollowThe field is used to control whether to add in the generated linkrel="nofollow"Property.rel="nofollow"It is an HTML attribute that informs search engines not to pass link page authority to the target page and also not to consider the target page as an endorsement of the current page.This is commonly used in SEO to handle user-generated content (such as links in comments) or external links that you do not want to pass SEO weight.In multi-language switch links, it is usually not setnofollowThese links are intended to help search engines discover other language versions of the website and pass related signals.But in some special cases, operators may have their own SEO strategy considerations and choose to enable it.

Related articles

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

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

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 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

How to iterate over the `languages` tag returned by the AnQiCMS template to list `websites`?

## Unlock the multilingual potential of AnQi CMS: How to efficiently traverse the `languages` tag returned by the `websites` list As an experienced website operations expert, I am well aware of the importance of multilingual websites in global marketing.AnQiCMS (AnQiCMS) relies on its powerful multi-site and multi-language support to provide a powerful tool for businesses and content operators to build internationalized websites.

2025-11-06

What is the role of the `LanguageName` field in the AnQiCMS multilingual site list?

In AnQiCMS, a system dedicated to providing efficient and customizable content management solutions, multilingual support is undoubtedly a core feature, especially crucial for enterprises targeting the global market or having audiences of different languages.When we delve into the multilingual site list of AnQiCMS, we will find that the `LanguageName` field plays a both intuitive and crucial role.

2025-11-06

What does the `Language` field represent in the AnQiCMS multilingual site list output?

## Unveiling the `Language` field in AnQiCMS multilingual sites: The 'identity' of international operation In AnQiCMS, an efficient and flexible enterprise-level content management system, multilingual support is one of its core highlights, aimed at helping businesses and content operators easily expand into international markets.When building and managing multilingual sites, we often encounter various fields related to language in templates or backend configurations.Among them, the `Language` field plays a crucial role in the output of the multilingual site list.

2025-11-06

How is the `LanguageEmoji` field used for the visual display of the multi-language interface of AnQiCMS?

How to add visual charm to the `LanguageEmoji` field in AnQi CMS?Today, with the increasing significance of globalization, multilingual support for websites has become crucial for reaching a wider audience.AnQi CMS is an efficient enterprise-level content management system, deeply understanding this, its built-in strong multi-language function is born for this.How important it is to guide users in choosing a language through clever visual elements when building an intuitive and friendly multilingual switch interface

2025-11-06