Manage and retrieve the URL link address of categories in AnQiCMS (AnQiCMS), which is a fundamental and important task in website operation.It is crucial to clearly know how to view and use these links, whether it is for content organization, search engine optimization (SEO), or user navigation.As a content management system dedicated to providing efficient and customizable solutions, AnQiCMS offers flexible and intuitive options in this regard.

Understanding the basic structure of Anqi CMS category URL

In AnQiCMS, the URL of the category is not constant and is affected by two main factors:The pseudo-static rules of the websiteandThe custom URL settings of the category itself.The pseudo-static rules of the website define the overall structure pattern of the URL (for example, whether it contains category IDs, category names, etc.), and the "custom URL" of each category is the specific part displayed in the URL for that category.The combination of these two results in the complete link that the user ultimately sees in the browser.

View and edit directly through the background management interface

The most direct way to view the URL link address of a specific category is to enter the AnQiCMS background management interface.

  1. Firstly, you need to log in to the AnQiCMS backend, then navigate to“Content Management”module.
  2. Under "Content Management", you will seeDocument Classificationoptions, click to enter.
  3. In this interface, the system will list all the categories on your website. You can click on any target category's“Edit”button (usually a pencil icon) to enter the editing page of that category.
  4. In the category editing page, you will find a name ofCustom URLThe field.This field is usually automatically generated based on the category name you enter, which can be a pinyin or English abbreviation, serving as a unique identifier for this category in the URL.gongsi-xinwenOf course, you can also manually modify this field according to your own needs to better match your brand or SEO strategy, but please ensure its uniqueness throughout the entire site.

This 'custom URL' is the key part that constitutes the actual access link of this category.Although it shows a relative path segment here, when combined with the pseudo-static rules configured on your website, it will form a complete, accessible category URL.https://yourdomain.com/category/gongsi-xinwen.html.

In the front-end template, dynamically obtain the category URL

In addition to viewing in the background, dynamically obtaining and displaying the URL links of categories in the frontend templates of the website is also a common requirement, such as building navigation menus, breadcrumb navigation, or referencing categories in content lists.This provides convenient and easy-to-use template tags for AnQiCMS.

To obtain the URL link of a single specific category, you can usecategoryDetailTags:

{# 获取ID为1的分类的链接 #}
{% categoryDetail categoryLink with name="Link" id="1" %}
<a href="{{categoryLink}}">访问分类</a>

In this code block:

  • {% categoryDetail categoryLink with name="Link" id="1" %}This line of code tells AnQiCMS to get the details of the category with ID 1 and assign its 'Link' attribute (i.e., the URL address) to a variable namedcategoryLink.
  • <a href="{{categoryLink}}">访问分类</a>:Subsequently, you can use this in HTML{{categoryLink}}to output the complete URL of the category and build a clickable link.

If you need to display multiple categories and their links in the navigation bar, sidebar, or other areas of the website,categoryListtags are more efficient:

{# 获取模型ID为1(如文章模型)的所有顶级分类列表 #}
{% categoryList categories with moduleId="1" parentId="0" %}
    <ul>
    {% for item in categories %}
        <li><a href="{{ item.Link }}">{{item.Title}}</a></li>
    {% endfor %}
    </ul>
{% endcategoryList %}

Here,categoryListauto will loop through the specified category, and will assign each category's detailed information (includingLinkandTitle) toitemvariable, you can then use{{ item.Link }}to obtain each category's URL address, and use{{ item.Title }}to display the classification name.

Through these template tags, no matter how your website backend adjusts the rules of pseudo-static links or the "custom URL" of categories changes, the template can automatically render the current effective and correct link address, greatly simplifying the maintenance work of front-end content.

The impact of pseudo-static rules on URL

AutoCMS can generate SEO-friendly URLs largely due to its powerful pseudo-static rule management feature. You can access it in the backend.“Function Management”modulePseudo-static rulesOption. Here, you can choose several built-in rules for pseudo-statics, such as "numeric pattern

For example, if you select the "Category Naming Pattern", the URL structure of the category will usually include the value of its "Custom URL" field, forming something like/category/your-category-name.htmlEnglish format.When you modify the 'custom URL' of a category in the background or switch the overall pseudo-static rules, AnQiCMS will intelligently update the corresponding link address to ensure the continuity of the website and help search engines better crawl your content.LinkThe properties will provide the complete and standardized URL for the ultimate user to access according to the currently effective pseudo-static rules.

Summary

In AnQiCMS, viewing and using the URL link address of a specific category is flexible and diverse. You can accessThe "Content Management" under "Document CategoryThis is the core part of the URL. At the same time, when developing the front-end of the website, you can cleverly usecategoryDetailandcategoryListWhytemplate tags to dynamically obtain the complete URL link of the categoryThese links will automatically adapt according to the pseudo-static rules of the website. Mastering these methods will make your content operation and website management on Anqi CMS more proficient.


Common Questions (FAQ)

  1. 问:Why does the "custom URL" I see under "Document Classification" in the background not match the actual link address accessed on the front end?答:This is because the 'Custom URL' field on the backend displays only a part of the URL, which needs to be combined with the 'URL Rewrite Rules' configured on your website to form the complete link that users actually access. For example, the 'Custom URL' might begongsi-xinwenIf your rewrite rule is set to 'Category Naming Pattern', then the actual link on the front end may behttps://yourdomain.com/category/gongsi-xinwen.htmlThe system ensures the simplicity of back-end editing while providing flexibility of front-end URLs and SEO-friendliness.

  2. 问:If I modify the 'custom URL' or URL rewriting rules of the category, what impact will it have on the website's SEO?答:Modifying the URL structure of the category may affect SEO, because search engines have indexed the old URL. To avoid losing search engine weight and users encountering dead links due to link changes, it is strongly recommended to go to the AnQiCMS backend immediately after making such changes.“Function Management” -> “301 Redirect Management”Set the appropriate 301 redirect.Redirect the old URL permanently to the new URL, which tells search engines that your page has moved and passes the authority of the old page to the new page, thus minimizing the negative impact as much as possible.

  3. Question: In the template, besides getting the URL of the current page category, can I also get the URL of other specified categories?答:Certainly. UsecategoryDetailwhen tagging, you can go throughidparameters ortokenparameters to specify which category's URL to retrieve. For example,{% categoryDetail categoryAboutLink with name="Link" token="about-us" %}you can retrieve the "Custom URL" asabout-usCategory link, even if the current page is not the category page.{% categoryDetail categoryNewsLink with name="Link" id="5" %}Then you can get the link address of the category with ID 5. This method provides great flexibility, making it convenient for you to reference a specific category on any page.