As an expert who is well-versed in website operation, I know that the standardization of website links is crucial for search engine optimization (SEO) and user experience.In such an efficient and powerful content management system as AnqiCMS, ensuring that category links are presented in absolute path format can not only improve the visibility of the website in search engines, but also facilitate the citation and sharing of content on external platforms.Today, let's delve into how to elegantly achieve this goal in AnqiCMS.

The foundation of optimizing SEO and external references: Understanding the value of absolute paths

Imagine when you share an article on social media, or hope that other websites refer to a specific category page on your site, if the link is a relative path (for example,/category/news),then these links will not be able to be parsed correctly in the external environment, resulting in a '404 Not Found' error, which will undoubtedly severely damage the user experience and the professional image of the website. And absolute paths (such ashttps://www.yourdomain.com/category/newsThe URL includes the complete protocol, domain, and path, and can accurately point to the target page regardless of where it is referenced.

For SEO, search engine crawlers tend to fetch and index absolute paths.A consistent absolute path can help search engines better understand the structure of a website, avoid duplicate content (accessing the same page through different relative paths), and ensure that link assets (such as external link weight) can be accurately transmitted.categoryListThe category link generated by the tag is an absolute path, an indispensable part of website operation.

Core mechanism: precise configuration of the website address (BaseUrl)

In AnqiCMS, all templates tags (includingcategoryList)Generated link, its base is the "Website Address" (BaseUrl) configured by the system. This is the key to determining whether your website link is a relative path or an absolute path.

Ensure thatcategoryListGenerated category link is an absolute path, the primary and most important step is to accurately configure the 'Website Address' in the 'Global Function Settings' of AnqiCMS backend.You can navigate to 'Background Settings' -> 'Global Function Settings' to find this option.

Operation Steps:

  1. Login to AnqiCMS admin panel.
  2. Navigate to "Admin Settings".
  3. Click on "Global Function Settings".
  4. In the "Website Address" input box, be sure to enter the complete address including the protocol (http://orhttps://)and the absolute address of the domain.For example, if your website domain isexample.com, and you have already configured the SSL certificate (this is strongly recommended,有利于SEO), then you should fill inhttps://www.example.com/. Make sure to include a slash at the end./.

AnqiCMS will use thisBaseUrlas the prefix for all internal generated links. When you arecategoryListin{{ item.Link }}the system will automatically translate thisBaseUrlConcatenated with the path part generated by the pseudo-static rules to form a complete absolute path. For example, ifBaseUrlYeshttps://www.yourdomain.com/The pseudo-static path of a certain category is/news/,then the final link generated will behttps://www.yourdomain.com/news/.

Link structure: The clever use of pseudo-static rules

AlthoughBaseUrlDecided that the 'prefix' of the link is an absolute path, but the structure of the link's 'body' is defined by AnqiCMS's pseudo-static rules (or URL rewrite rules).AnqiCMS's pseudo-static feature is very flexible, allowing you to customize the display form of URLs, which is crucial for SEO-friendly URLs.

Operation Steps:

  1. Navigate to "Function Management".
  2. Click on "Pseudo-static Rules".
  3. Select or customize a URL rewrite rule that suits your website needs.

For example, you may want category links to be/category/{catname}.html(model naming pattern), or/list-{catid}.html(numeric pattern), or/news/tech/(Classification naming pattern)。No matter which mode you choose, as long as you configure the full domain name in the "Website address",categoryListthe tag in{{ item.Link }}it will automatically generate withhttps://www.yourdomain.comAn absolute path starting with '为'.

It is important to understand that the pseudostatic rules define the path part of the URL,网站地址This provides the domain name and protocol of the path. Both are required to generate an absolute path in the true sense.

Natural call in the template:categoryListSimplified usage of

in AnqiCMS template files, usingcategoryListtags to display category lists is very intuitive. When you have completed the above,网站地址After configuring the pseudo-static rules, you do not need to make any special treatments in the template code to obtain absolute path links.

Example code:

{% categoryList categories with moduleId="1" parentId="0" %}
<ul>
    {% for item in categories %}
    <li>
        <a href="{{ item.Link }}">{{item.Title}}</a>
        {# item.Link 将自动输出如 https://www.yourdomain.com/category/news/ 这样的绝对路径 #}
    </li>
    {% endfor %}
</ul>
{% endcategoryList %}

Here,{{ item.Link }}It will automatically generate complete, SEO-friendly absolute paths based on your global website address settings and pseudo-static rules. Whether it is an article list, product list, or Tag list, ititem.LinkThe generation logic of the attribute is similar, all depend on网站地址configuration.

Extended thinking: additional practices to improve SEO

In addition to ensuringcategoryListGenerate absolute path, in addition, there are also some related SEO practices worth your attention:

  • Sitemap generation:AnqiCMS has built-in Sitemap generation functionality. A correct网站地址Configuration is a prerequisite to ensure that all URLs in the Sitemap are absolute paths, which helps search engines discover and index all your important pages.
  • Canonical tag:For pages that may have multiple access paths (such as, URLs with parameters or the same article under different categories), usetdkthe tag inCanonicalUrlProperty to specify a unique specification URL, and ensure that this specification URL is an absolute path, which can effectively avoid content duplication issues.
  • 301 Redirect:If your URL structure changes (for example, from/category.html?id=1Changes to/news/tech.html),MUST set 301 permanent redirect.AnqiCMS provides 301 redirect management function, ensuring that old links can transition smoothly to new links, avoiding traffic loss and SEO demotion.

In summary, to implement in AnqiCMS,categoryListGenerate the link to the absolute path, the core of which lies in the correct configuration of 'Website Address' in the 'Global Function Settings' on the backend.With flexible pseudo-static rules and simple template tag calls, your website will be able to provide a better user experience and perform better in search engines.

Common Questions (FAQ)

**Q1: I have set 'Website Address' tohttps://www.yourdomain.com/? ButcategoryListThe generated link is still displayed on the front end/news/What's wrong with this relative path?