As a website operator who deeply understands the operation of AnQi CMS, I am very clear that in today's global market, the importance of multilingual websites and how to use refined SEO strategies, such ashreflangTags to enhance the international visibility of the website. Anqi CMS's flexibility in multilingual support and template customization provides a solid foundation for us to achieve these goals.

Now, let's delve into how to effectively configure and display in the Anqi CMS templatehreflangTags to ensure that your multilingual site is correctly geolocated and language localized in search engines.

UnderstandinghreflangThe role of tags in multilingual sites.

hreflangTags are key elements of search engine optimization (SEO), especially for multilingual websites targeting users in different languages or regions.It indicates to the search engine the language and geographic region of a specific page, and informs the search engine that the page exists in other language or regional versions.Use correctlyhreflangLabels can avoid the issue of multilingual content being considered duplicate content, while also ensuring that users can see the version of the page that best matches their language and regional preferences when searching, thereby greatly enhancing user experience and the international SEO performance of the website.

The Anqi CMS, with its powerful 'multi-site management' and 'multi-language support' core functions, provides a natural advantage for building such websites.It allows you to create independent sites or content branches for different languages or regions and manage this content flexibly in the background.

Utilizing AnQi CMS'slanguagesLabel constructionhreflang

In the Anqi CMS template system, we have a special design for multilingual siteslanguagesThe tag can help us dynamically obtain all the multilingual site information that is configured, thereby generating the correcthreflang.

Firstly, we need to ensure that your Safe CMS backend is properly configured with multiple language sites.This usually involves adding different sites in the "multi-site management" and specifying the corresponding "default language package" and "website address" for them.These backend configurations arelanguagesThe tag is the basis for correctly obtaining data.

In the template,languagesThe usage of tags is as follows:

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

This code snippet should be placed in the public header template file of your website, for examplebase.htmlof<head>within the area. This ensures that each page includes the completehreflanginformation.

Let me explain the key part of this code:

  • {%- languages websites %}This is calling the built-in of Anqi CMS:languagesThe tag will query all the multi-language sites configured on the system backend and assign these sites' data as an array to a variable namedwebsites.
  • {%- for item in websites %}We useforLoop throughwebsitesEach site entry in the array. In each iteration, the details of the current site will be assigned toitemVariable.
  • <link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">: This is the corehreflangof label generation.
    • rel="alternate"This indicates an alternative version.
    • href="{{item.Link}}":item.LinkThe variable will output the absolute URL of the current language site. For example, if your English site ishttps://en.example.com/about-us.html, then it will be used as the tag of thehrefMake sure that the "Website URL" configured in the background is a complete absolute URL to avoid any parsing issues.
    • hreflang="{{item.Language}}":item.LanguageThe variable will output the language code of the current language site, for example “en” (English), “zh-CN” (Simplified Chinese, Mainland China) or “fr-CA” (French, Canada region).These language codes should strictly follow the ISO 639-1 language codes and ISO 3166-1 Alpha 2 country/region codes standard.The default language package setting in the AnQi CMS backend will directly affect this location.item.LanguageValue.

In this way, when a search engine crawls your page, it will find all links pointing to itself and all other language or regional alternative versionshreflangLabels, so that you can correctly understand the multilingual structure of your website.

x-defaultconsideration

Except to specify for each language version,hreflangLabels, we usually also set up ahreflang="x-default"The tag indicates which page should be displayed as the default or general version when no other language or regional version matches the user's settings.For example, you can point it to your main language page, or a language selector page.

Although Anqi CMS'slanguagesThe tag provides links to all language versions directly, but it does not have a specific field to mark which one isx-defaultthe version. To achievex-defaultYou may need to make additional judgments or configurations.

A common method is toforOutside or inside the loop, based on specific logic (such as judgmentitem.LanguageIs it your default language or an additional one output through custom backend settings?x-defaultLabel. For example, you can specify your main site (such as the English site) asx-default:

<link rel="alternate" href="{% system with name='BaseUrl' %}" hreflflang="x-default">

Here{% system with name='BaseUrl' %}It will output the URL of your main site (default site), you can adjust it according to your actual needs to be any URL you want to usex-defaultURL.

Summary

ConfigurationhreflangTags are an important step for multilingual websites to carry out international SEO optimization.AnQi CMS, with its flexible template engine and multi-language, multi-site management functions, provides us with a convenient implementation path.By simply puttinglanguagesTag integrated into your template header, and combined with thex-defaultThe reasonable setting, you can effectively convey the language and geographic positioning information of your website to search engines, thereby improving the visibility and user experience of your website globally.


Frequently Asked Questions (FAQ)

1. If my multilingual site is set up in a subdirectory (for exampleexample.com/en/,example.com/fr/) rather than a standalone domain or subdomainhreflangis the configuration method of the tags different?

No matter where your multilingual site is deployed in a standalone domainexample.com/example.de), subdomainen.example.com/de.example.com), or subdirectoryexample.com/en//example.com/de/) under,hreflangThe logic for generating tags is basically consistent. Anqi CMS'slanguagesThe tag while traversing different language sites,item.LinkThe variable will automatically output the complete URL of the language site, whether in subdirectory form or as a standalone domain.The key is that you have correctly configured the 'website address' for each language site in the 'Multi-site Management' section of the Anqi CMS backend.As long as the website address is filled in correctly,hreflangin the labelhrefthe attribute will automatically become the correct absolute URL.

2. I need to ensure that each page'shreflangDo the tags point to the correct alternative versions? For example, the English 'About Us' page should point to the French 'À Propos de Nous' page.How does AnQi CMS handle page-level issueshreflang?

Yes,hreflangTags are usually at the page level. Anqi CMS'slanguagesTags obtain the relative path of the current page and combine it with the 'website address' of each language site to build the completeitem.LinkThis means that if you usebase.htmlthe abovelanguagestag code, then when the user accesseshttps://en.example.com/about-us.htmlthen,item.Linkit will behttps://fr.example.com/about-us.html(Assuming the root URL and page path structure of your French site is consistent). If the page paths for different language versions are different (for example, the URL for the French page is/a-propos.html), you need to set the correct 'custom URL' in the background content management for the corresponding multilingual page, or map the page paths under different languages through more complex template logic.The '伪静态规则' and 'custom URL' features of AnQi CMS can help you flexibly manage these page paths.

3. How to add labels for my multilingual sitex-default hreflangto indicate the default or alternative page? Does AnQi CMS have built-in settings?

Of Security CMSlanguagesTags are mainly used to list all the multi-language sites configured and their language codes. It does not have a built-in feature to mark or identifyx-defaultthe version field. To addx-default hreflangLabel, you usually need to add an extra one in the templatelinkThis can be achieved by manually specifying a page URL, for example:<link rel="alternate" href="https://www.example.com/" hreflang="x-default">Herehttps://www.example.com/Should be the URL of your general or default language page. You can combine{% system with name='BaseUrl' %}tags to dynamically retrieve your main site URL and use it forx-defaultofhrefThe value. If your website logic is complex, it needs to be dynamically selected based on certain conditionsx-defaultThe page may require implementing this goal by customizing fields in the background or writing more advanced template logic.