In website operation, Search Engine Optimization (SEO) is a key factor in improving website visibility and attracting targeted user traffic.Among them, how to effectively handle duplicate content and normalize URLs are important details that cannot be ignored in SEO strategies.English CMS (EnglishCMS) as a system designed for content operation teams, provides powerful and flexible functional support in this aspect.CanonicalUrlHow to work together with the URL parameter escaping feature in AnQiCMS to optimize the website's SEO performance.
The core value of the (CanonicalUrl) in SEO in English
Firstly, we need to understandCanonicalUrlThe function of (standard link).When there are multiple pages with the same or extremely similar content on a website (for example, through different channels tracked URLs, pages with sorting or filtering parameters, and print version pages, etc.), search engines may consider them duplicate content, which not only distributes the page weight, but may also affect the overall ranking of the website.The purpose of the canonical link is to inform search engines: 'This URL is the preferred version of this page content, please concentrate all the weight and signals on this URL.'}]
In AnQiCMS, setting up standard links is an intuitive and important operation.In the document or page editing interface of the content management backend, there is usually a dedicated field that allows you to specify a standard link for the page.This link should point to the 'cleanest' URL version that you want search engines to index and rank.product.html?sort=price_ascandproduct.html?sort=price_desc等多个URL,但其核心内容是一致的。此时,您可以将这两个页面的规范链接都设置为Englishproduct.html.
在模板中,AnQiCMS 提供了EnglishtdkLabels for convenient output of standard links. You can use the following code on the page<head>Region:
{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}
This code will first check if a specification link is set for the current page, if set, it will generate in the HTML<link rel="canonical">Label, clearly indicate the preferred URL of this page to search engines.
URL parameter escaping: eliminate SEO risks.
URL parameters are very common on websites, they can implement various dynamic functions, such as tracking user sources, filtering products, page sorting, etc.However, these parameters also bring SEO challenges.example.com/page?id=123&source=baiduandexample.com/page?id=123It may be considered as two different pages, which may result in duplicate content issues.In addition, if parameters containing special characters are not handled correctly, it may also lead to chaos in the URL structure, affecting the efficiency of web crawling.
AnQiCMS provides pseudo-static functionality, which can convert dynamic URLs into more semantically meaningful and SEO-friendly forms, such asexample.com/category/article-title.html.This greatly reduces the impact of parameters on the URL.However, when it comes to certain scenarios that require parameters to be used, or when dynamically building links with parameters in templates, ensuring the correct escaping of parameters becomes particularly important.
AnQiCMS's template engine is built-inurlencodeandiriencodeEnglish filters used to handle URL parameter escaping.
urlencodeThe filter will percent-encode all special characters in the URL (for example, spaces become)%20,&Changes to%26This ensures that the URL can be correctly parsed in different systems and browsers, avoiding URL parsing errors or security issues caused by special characters.{{ "http://www.example.org/foo?a=b&c=d"|urlencode }} {# 显示结果: http%3A%2F%2Fwww.example.org%2Ffoo%3Fa%3Db%26c%3Dd #}iriencodeThe filter is more focused on the encoding of internationalized resource identifiers (IRI), it will encode the URL parameters except for/#%[]=:;$&()+,!?*@'~These characters outside the common URL components are encoded. It is usually used to handle URL paths or query strings containing non-ASCII characters (such as Chinese).{{ "?foo=123&bar=yes"|iriencode }} {# 显示结果: ?foo=123&bar=yes #}
When you dynamically generate links in a template and the link parameters may contain user input or complex data extracted from a database, using these escape filters is**practical.
CanonicalUrl 与 URL参数转义的协同作用
CanonicalUrl and URL parameter escaping work together to optimize SEO, not independently, but rather in coordination, jointly providing clear and accurate signals to search engines.
Imagine a scenario: You have a product detail page, with specifications link ishttps://yourdomain.com/products/awesome-product.html. However, there may be some internal links on this page, used to filter different colors or sizes of the product, such ashttps://yourdomain.com/products/awesome-product.html?color=red&size=large.
In this case:
The role of CanonicalUrl:It explicitly tells the search engine, regardless of whether the user goes through
?color=redThis is other parameter access, all these pages with parameters should be attributed tohttps://yourdomain.com/products/awesome-product.htmlthis specification page. This avoids the problem of duplicate content and concentrates the SEO weight.The role of URL parameter escapingWhen you generate in the template
?color=red&size=largesuch internal links, ifcolororsizethe value itself may contain special characters (such as,color=深蓝&型号=X L), then usingurlencodeFiltering these parameter values is crucial.{% set base_url = "/products/awesome-product.html" %} {% set color = "深蓝" %} {% set size = "X L" %} <a href="{{ base_url }}?color={{ color|urlencode }}&size={{ size|urlencode }}">查看深蓝XL款</a>This ensures that the generated links are valid and will not be incorrectly identified or parsed by search engines due to special characters, which can affect the crawling of internal links.
Although CanonicalUrl is mainly used to declare the preferred version of a page, if due to some special requirements, the specification link itself is constructed according to dynamic parameters (although it is not recommended, it may exist in extreme cases), then ensure that any dynamic parameters in the specification link are properly escaped to ensure its own validity and correct understanding by search engines.
In short, AnQiCMS providesCanonicalUrlsettings andurlencode/iriencodeParameter escaping function is a pair of sharp tools for website operators in refined SEO management.The standard link points out the direction for search engines, while parameter escaping ensures the health and clarity of the internal link structure of the website.Combining both can effectively solve SEO problems such as duplicate content and low crawling efficiency, thereby improving the performance of the website in search engines.
Common Questions (FAQ)
1. Since pseudo-static has been used, why is it still necessary to set CanonicalUrl?The pseudostatic mainly optimizes the structure of the URL, making it more readable and SEO-friendly, but it cannot completely avoid the generation of duplicate content. For example, through advertisement tracking links (yourdomain.com/page?utm_source=ad)、不同的排序/筛选参数(yourdomain.com/page?sort=date)或者用户会话ID(`yourdomain.com/page?sessionid