Today, with the deepening of globalization, many enterprises and content operators need to provide customized content for users of different languages or regions. In order to ensure that these multilingual versions can be correctly identified by search engines and displayed to target users,hreflangThe correct setting of tags is particularly important. For friends who use AnQiCMS to build multilingual websites, the system built-inlanguagesTags are a powerful tool to solve this problem.
UnderstandinghreflangThe importance of tags
Before we delve deeper into how AnQiCMS helps us set uphreflangLet's take a look back first.hreflangThe role of tags. Simply put,hreflangTags are a signal to search engines that "this page has other language or regional versions." For example, if your website has a "product introduction" page with Chinese, English, and Japanese versions, then byhreflangYou can tell Google and other search engines:
example.com/zh/productIs in Chinese versionexample.com/en/productIs in English versionexample.com/jp/productIs in Japanese version
Correct settingshreflangSeveral significant benefits:
- Avoid duplicate content issues:Search engines will not treat content in different language versions as duplicate content, which can affect ranking.
- Improve user experience:Search engines can automatically guide users to the most suitable language version of the page based on their language preferences and geographical location, reducing the bounce rate.
- Optimize international SEO:Make sure your content can accurately reach the target audience in different global markets.
AnQiCMS, as a system designed for multi-site management and multilingual promotion, naturally willhreflangThe implementation considerations are taken into account, and a concise and efficient solution is provided.
How AnQiCMS simplifies multilingual SEO:languagesTag debut
AnQiCMS took full consideration of multilingual content management needs from the very beginning.It supports the switching and display of multilingual content, which can help operators easily expand into international markets.In the "Multi-site Management" backend, we can configure sites in different languages, set their language packs and corresponding access addresses.These configurations are set tohreflangThe generation of tags provides basic data.
In the AnQiCMS template system,languagesThe tag is specifically used to retrieve the list of all configured multilingual sites.This tag does not accept any parameters, executing it will return an array object containing information about all language sites.We can traverse this array and dynamically generatehreflangrequiredlink.
Practice: Configuring in AnQiCMS templatehreflangTag
hreflangTags are usually placed in the HTML document's<head>Within a block. In AnQiCMS, this means you need to be in the public header file, usuallybase.htmlConfigure in a similar template file to ensure it acts on all related pages.
Let's see the specific template code example:
{%- languages websites %}
{%- for item in websites %}
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
{%- endfor %}
{%- endLanguages %}
The core logic of this code is:
{%- languages websites %}: Invokelanguagestag, assigning information to all multilingual sitewebsitesVariable. In itwebsitesIs an array object.{%- for item in websites %}:Traversewebsitesarrayitemfor eachitemRepresents a language site.<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">: This is generatedhreflangthe key tag.rel="alternate": This is a backup version.href="{{item.Link}}":item.LinkDynamically outputs the complete link address of the current page on the corresponding language site. AnQiCMS intelligently handles this part, ensuring that the link points to the correct language version page.hreflang="{{item.Language}}":item.LanguageThe language code of the site will be output, for examplezh-cn(Simplified Chinese),en-usor (American English)deGerman language codes need to be correctly configured in the AnQiCMS backend language package settings.
Through the above code, AnQiCMS will automatically generate the corresponding language versions for the current pagehreflangtags. For example, if you have a Chinese pageexample.com/zh/page1and configured the English siteexample.com/en/page1, you can beexample.com/zh/page1of<head>there will be a pointerexample.com/en/page1ofhreflangtags, vice versa.
Ensurehreflangsome considerations for setting correctly
It's not enough to just add the code to the template, in order tohreflangThe label plays the most effective role, we also need to pay attention to several key points:
- The accuracy of the site language code:
item.LanguageThe language code must comply with the ISO 639-1 standard. If regional information is needed, it should be combined with the ISO 3166-1 Alpha 2 country code (for exampleen-gbRepresents British English). Make sure to correctly select the "default language package" in the "Global Function Settings" of AnQiCMS. - All language version pages must include
hreflang:Each page that exists in multiple languages should include links to itself and all other language versions.hreflangTags. AnQiCMS'languagesLabels are designed for this, it will traverse all language sites. - Bidirectional reference: If page A points to page B, then page B must also point to page A. This is a two-way reference that is
hreflangThe cornerstone of effectiveness, ensuring that search engines can fully understand your multilingual structure. x-defaultThe use of tags (optional but recommended):Although AnQiCMS'slanguagesTags are mainly used to generate links for specific language versions, but to provide a "default" or "fallback" version, you may consider adding an extra onex-defaultThe tag tells the search engine which page to display when the user's language or region does not match any specified version.For example, you can set the URL of the main site tox-default:
Here<link rel="alternate" href="{% system with name="BaseUrl" %}" hreflang="x-default">{% system with name="BaseUrl" %}Used to get the base URL of the current site.- Content Consistency:Ensure that the content of different language versions is an accurate translation of the corresponding language, not machine translation or low-quality content. High-quality multilingual content is
hreflangthe essence of success. - Test and verification:After configuration is complete, be sure to use Google Search Console and other tools to verify, check
hreflangwhether the tags are recognized correctly and there are no errors.
By fully utilizing the multi-language support features of AnQiCMS andlanguagestag,