How to display the language switch options and hreflang tags on Anqi CMS?

Calendar 👁️ 68

In today's increasingly globalized world, providing multilingual support for websites has become a basic requirement for expanding the market and serving users in different regions.AnQiCMS (AnQiCMS) is well aware of this need, built-in powerful multilingual functions, allowing website administrators to easily achieve content internationalization.This article will discuss in detail how to effectively display the language switch options of the AnQiCMS site and set it up correctlyhreflangTag, to optimize the internationalization identification of search engines.

Understand AnQiCMS multilingual capabilities

AnQiCMS is an efficient and customizable content management system, its project advantages are clearly pointed out to support the switching and display of multilingual content, aiming to help enterprises expand into the international market.This means that the system not only provides the infrastructure for content management, but also simplifies the deployment and maintenance of multilingual sites.In the AnQi CMS backend, we can create different language versions of sites through the "Multi-site Management" feature, and adjust the "Default Language Pack" in the "Global Settings" to provide localized browsing experiences for users of different sites.

Display the language switch option for multi-language sites.

To facilitate users switching between different language versions, it is usually set up a language switcher in a prominent position on the website (such as the navigation bar, footer). In AnQiCMS, this can be done throughlanguagesThe template tag can be easily implemented.

languagesThe tag can retrieve the list of all configured multilingual sites. It does not require any parameters, it is used directly.{% languages websites %}You can get an array containing information about all language sites. Then, we can iterate through the array to generate a link for each language site.

Information about each language site (item) includes many useful fields, such as:

  • LanguageName: The display name of the language (such as "Simplified Chinese", "English").
  • LanguageLanguage code (such as "zh-CN", "en"), this ishreflangthe key tag.
  • LanguageEmoji: Represents the language emoji (such as 🇺🇸, 🇨🇳).
  • LanguageIconIf configured, it can display the icon corresponding to the language.
  • LinkThe URL address of the language site, used for users to click and switch.

Here is an example of a language switcher implemented in the template:

{%- languages websites %}
{%- if websites %}
<div class="language-switcher">
    <span>切换语言:</span>
    {%- for item in websites %}
    <a href="{{item.Link}}" class="language-option">
        {%- if item.LanguageIcon %}
        <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}} Flag" class="language-flag" />
        {%- else %}
        <span class="language-emoji">{{item.LanguageEmoji}}</span>
        {% endif %}
        <span class="language-name">{{item.LanguageName}}</span>
    </a>
    {%- endfor %}
</div>
{%- endif %}
{%- endLanguages %}

This code will traverse all configured language sites and create a link for each site.If the site is configured with an icon, the icon will be displayed; otherwise, the language's emoji will be displayed.Click the link and the user can easily navigate to the corresponding language version of the page.

ImplementationhreflangLabel for optimizing SEO

hreflangTags are crucial for the search engine optimization of multilingual and multiregional websites.It can tell search engines which pages are alternative versions of the same content, and specify the target language and geographic region of these versions.This helps search engines provide users with the most relevant language or region pages, while avoiding penalties for duplicate content.

Combined with AnQiCMS,languagestags, we can also generate them conveniently.hreflangTags. These tags are usually placed in the HTML document.<head>Within the area.

The following is on the page<head>Partially addhreflangLabel example:

<head>
    {# 其他head内容... #}

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

</head>

This code will generate corresponding language versions for all configured languages on the current page.hreflanglinks.item.LinkIt ensured that the link points to the correct language page, anditem.Languagethen provided the standard language codes such asenrepresents English,zh-CNRepresents Simplified Chinese. Properly setting these tags will greatly improve the performance of the website in international search engines.

Considerations in practice

In practical operation, there are several aspects that deserve attention. First, make sure that each language site and its corresponding domain or subdirectory/subdomain is correctly set in the "Multi-site Management" section of the AnQiCMS background.Secondly, in the "Global Settings" option of the "Default Language Pack", specify an appropriate language for each site. This usually determines the backend interface language of the site and some system default prompts.It is most important that, although AnQiCMS provides a switching mechanism, the content translation work for each language site still needs to be done manually to ensure that users receive high-quality, accurate localized information.

By using the above method, you can effectively set up and manage multilingual websites in AnQiCMS, not only enhancing user experience, but also through precisehreflangSet to ensure that your internationalized content is correctly indexed and displayed by global search engines, thereby reaching a wider audience.


Frequently Asked Questions (FAQ)

Q1: How to configure different language version sites in the AnQiCMS backend?A: You can create new sites using the 'Multi-site Management' feature and specify independent domains or paths when creating or editing sites.Later, in the "Global Settings" of each site, you can select the site's "default language package", which will affect the internal language settings and the display of some default texts.Content in different languages (articles, products, etc.) should be published and managed under their respective sites.

Q2: SettingshreflangWhat are the specific benefits of tags for international SEO of the website?A:hreflangLabels have three main advantages:

  1. Avoid repetition content penaltyIt informs search engines that different URLs correspond to language or region-specific versions of the same content, rather than plagiarism or duplication, thus avoiding SEO negative impacts.
  2. Improve the ranking of localized content: Search engines can prioritize the display of the most relevant pages based on the user's language and location, thereby improving the search ranking of your localized content in the target market.
  3. Enhancing user experienceThe user can directly see the page that matches their language and regional preferences in the search results, reducing the trouble of manual switching, reducing the bounce rate, and improving the conversion rate.

Q3: How do I only display the language switch option on specific pages?A: The display of language switch options depends entirely on your template design. You just need to place the above language switcher code snippet in the specific template file where you want it to be displayed (such asheader.html/footer.htmlIn the or a specific page template, you can do this. If you only want to display the code on a few pages, you can add it only to these page template files; if you want to display it throughout the entire site, it is usually placed in the publicbase.htmlorheader.htmlTemplate in.

Related articles

How does the `breadcrumb` tag in AnQi CMS generate and display flexible breadcrumb navigation?

When building a website, a clear and intuitive navigation system is crucial for user experience and search engine optimization (SEO).Breadcrumb navigation is a tool that can significantly improve website usability, clearly showing the user's current position on the site and providing convenient links to return to the previous level page.AnQi CMS knows this and provides a powerful and flexible `breadcrumb` tag.###

2025-11-09

How to define and display temporary variables in Anqi CMS template for complex content layout?

In website content operation, we often encounter some scenes where we need to flexibly display data and dynamically adjust the layout.Sometimes listing information simply is not sufficient to meet complex design requirements, and at this point, if you can freely define and use some temporary variables in the template, it will greatly enhance our efficiency and the expressiveness of the template.AnQiCMS (AnQiCMS) with its powerful backend developed based on the Go language and the template engine syntax similar to Django, provides us with a flexible mechanism for defining and managing temporary variables, making it possible to create exquisite and complex content layouts.Define a temporary variable

2025-11-09

How can AnQi CMS display a list of recommended articles related to the current article content?

In website operation, providing a list of recommended articles related to the current content is an important strategy to enhance user experience, extend user stay time, and optimize website internal links.AnQiCMS (AnQiCMS) knows this and provides flexible and powerful features to help you easily achieve this goal.### Core Function Analysis: Related Document Tag `archiveList` To display a list of recommended articles related to the current article content in AnQi CMS, you will mainly use a very key template tag—`archiveList`

2025-11-09

How to add captcha display to the comment feature of Anqi CMS to enhance security?

Maintaining a healthy, interactive website comment section is an indispensable part of content operation.However, comment sections often become hotbeds of spam and malicious attacks, which not only affects the quality of the website's content but also brings additional review burdens to website administrators.To effectively resist the interference of these automated programs, adding a captcha display to the comment feature of AnQi CMS is a simple and practical security enhancement measure.

2025-11-09

How to implement the sorting display of article list by views (views desc) in AnQi CMS?

How to make a hot article on the website stand out quickly and attract more visitors' attention?This can effectively enhance user experience and is also the key to optimizing content strategy and guiding traffic.For users of AnQiCMS, it is a very practical and easy-to-operate feature to display article lists sorted by page views.The powerful template tag system of AnQi CMS allows you to easily display the most popular content on your website to users.### Core Feature Revelation: Utilize `archiveList`

2025-11-09

How to implement complex parameter filtering conditions for the dynamic display of the `archiveFilters` tag on the front end?

In website content operation, providing users with flexible and efficient filtering functions is an important factor in improving user experience and helping users quickly locate the information they need.AnQiCMS (AnQiCMS) knows this, making it easy to dynamically display complex parameter filtering conditions on the front end through its powerful template tag system, especially the `archiveFilters` tag.### Core Function and Implementation Principle The core function of the `archiveFilters` tag is to use the custom fields of the content model

2025-11-09

How to call the backend custom Json-LD structured data in AnQi CMS template and display it?

Today with the rich content on websites, how to make search engines accurately understand web content and display it in a more user-friendly manner has become a key link in website operation.Structured data (usually in Json-LD format) is an important tool to achieve this goal.By embedding Json-LD code in the page, we can provide standardized information for search engines about various content such as articles, products, and reviews, thereby having the opportunity to obtain richer search result displays, which is what we commonly refer to as 'rich snippets' or 'rich results'

2025-11-09

How does Anqi CMS handle and display external links in content, such as adding the `rel="nofollow"` attribute?

In website operation, the management of external links is an indispensable part of content strategy and search engine optimization (SEO).Especially properties like `rel="nofollow"`, which tell search engines not to pass link weight to the linked page, are crucial for managing the link health of a website and avoiding potential SEO risks.AnQiCMS (AnQiCMS) provides multiple ways to handle and display external links in content, including automatically adding the `rel="nofollow"` attribute

2025-11-09