As a website operator who is deeply familiar with the operation of security CMS, I am very clear about the importance of multilingual websites in today's global market and how to implement fine-grained SEO strategies such ashreflangTags, to enhance the international visibility of the website. The flexibility of Anqi CMS 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 templatehreflangLabel, to ensure that your multilingual site is correctly geolocated and language localized in search engines.
UnderstandhreflangThe role of the label in multilingual sites.
hreflangTags are the key elements of search engine optimization (SEO), especially for multi-language websites that target users of different languages or regions.It specifies the language and geographical region for a specific page to search engines, and informs search engines that there are other language or regional versions of the page.hreflangLabels 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, thus greatly enhancing user experience and the international SEO performance of the website.
Anqi CMS provides a natural advantage for building such websites through its powerful 'multi-site management' and 'multi-language support' core features.It allows you to create independent sites or content branches for different languages or regions, and manage these contents flexibly in the background.
Utilizing the AnQi CMSlanguagesLabel constructionhreflang
In the template system of AnQi CMS, we have a special design for multilingual siteslanguagesThe tag that helps us dynamically retrieve all configured multilingual site information and generate the correct.hreflangTag.
Firstly, we need to ensure that your security CMS backend has been properly configured with multiple language sites.This usually involves adding different sites in the "Multi-site Management" and specifying the corresponding "default language pack" and "site address" for them.languagesThe basis for the tag to correctly retrieve data.
In the template,languagesHow to use the label 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 example:base.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 the call to the built-in of CMSlanguagesLabels, it will query all multilingual sites configured on the system backend, and assign these sites' data as an array to a variable namedwebsites.{%- for item in websites %}We useforto iterate overwebsitesEach entry in the array. In each iteration, the details of the current site will be assigned.itemthe variable.<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">This is the core.hreflangLabel generation part.rel="alternate"This indicates that this is a substitute 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'shrefEnsure that the 'Website Address' 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.item.LanguageEnsure that the 'Website Address' configured in the background is a complete absolute URL to avoid any parsing issues.
This way, when search engines crawl your page, they will find all links to its own version and all other language or regional alternatives.hreflangLabels, so that you can correctly understand the multilingual structure of your website.
x-defaultconsiderations
in addition to specifying for each language versionhreflangwe will also usually set up ahreflang="x-default"Label.This tag indicates which page the search engine should display as the default or general version when there is no other language or region version matching the user's settings.For example, you can point it to your main language page, or a language selector page.
although the security CMSlanguagesLabels directly provide links to all language versions, but it does not have a specific field to mark which one isx-defaultto 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 judgment)item.LanguageIs it your default language, or output an extra one through custom backend settings?)x-defaultLabel. For example, you can specify your main site (such as an English site) asx-default:
<link rel="alternate" href="{% system with name='BaseUrl' %}" hreflflang="x-default">
here{% system with name='BaseUrl' %}The output will be the URL of your main site (default site), which you can adjust according to your actual needs to be any site you want asx-defaultURL.
Summary
ConfigurehreflangTags are an important step for multilingual websites to carry out international SEO optimization.AnQi CMS provides a convenient implementation path with its flexible template engine and multi-language, multi-site management features.languagestag integration into your template header, and combine with thex-defaultThe reasonable settings enable you to effectively communicate the language and geographic location of your website to search engines, thereby enhancing 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/) instead of a standalone domain or subdomain,hreflangis the configuration method for tags different?
No matter where your multilingual site is deployed, whether on a standalone domain (example.com/example.de), a subdomain (en.example.com/de.example.com), or a subdirectory (example.com/en//example.com/de/),hreflangthe logic for generating tags remains basically consistent. The security CMS oflanguagesLabels are automatically generated as the correct absolute URL when traversing different language sites.item.LinkThe variable will automatically output the full URL of the language site, whether in subdirectory form or as an independent domain name.The key is that you have correctly configured the 'site address' for each language site in the 'Multi-site Management' section of the Anqi CMS backend.hreflangIn tags,hrefProperties are automatically generated as the correct absolute URL.
2. I need to ensure that each page'shreflangDo all the tags point to their correct alternative versions?For example, the English "About Us" page should link to the French "À Propos de Nous" page.hreflang?
Yes,hreflangTags are usually page to page level. Anqicms'slanguagesTags are constructed by obtaining the relative path of the current page and combining it with each language site's “website address”item.LinkThis means, if you have used the aforementionedbase.htmlinlanguagestags in the code, then when the user accesseshttps://en.example.com/about-us.htmlwhenitem.Linkwill behttps://fr.example.com/about-us.html(Assuming your French site's root URL and page path structure remains consistent). If the page paths for different language versions differ (for example, the French page URL is/a-propos.htmlYou need to set the correct 'custom URL' in the background content management for the corresponding multilingual page, or use more complex template logic to map page paths under different languages.The "伪静态规则" and "自定义URL" feature of Anqi CMS can help you flexibly manage these page paths.
3. How to add languages to my multilingual sitex-default hreflangTags to indicate the default or alternative page? Does Anqí CMS have built-in settings?
Anqi CMS'slanguagesLabels are mainly used to list all configured multilingual sites and their language codes. It does not have a built-in field for marking or identifyingx-defaulta version field. To addx-default hreflangLabel, you usually need to add an additional line in the templatelinkLabel. This can be achieved by manually specifying a URL of a page, 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-defaultofhrefValue. If your website logic is complex and requires dynamic selection based on certain conditionsx-defaultPage, you may need to achieve this by customizing fields in the background or writing more advanced template logic.