In website operation, friendship links (also known as cooperative website links) play an important role.They not only bring additional traffic to the website, but also help to improve search engine optimization (SEO) performance, enhance the authority and user trust of the website.In AnQi CMS, managing and displaying these links becomes very convenient, mainly due to its powerful template tag system, especiallylinkList.

Flexible display of cooperative websites:linkListThe purpose and basic principles of the tag

linkListThe tag is a powerful tool designed by Anqi CMS specifically for handling friendship links.It can dynamically retrieve all the partner website link information you have pre-configured from the background database and display it in any location on the website front end.This means that once you update the friend links in the background, the front-end page will display the latest content without manual code modification, greatly enhancing the efficiency of content management.

UselinkListLabel, you can easily build a friend link block, whether placed in the website footer, sidebar, or a special "Partners" page.It returns a list object containing all the friendship link information, and you can display it one by one like you handle a normal data list.

How to uselinkListThe tag displays friendship links on the website

To call and display friendship links in your Anqi CMS template, you need to follow a set of simple syntax rules.

First, you need to use{% linkList 变量名称 %}Declare a variable that will hold all the friend link data. For example, we can name itfriendLinks:

{% linkList friendLinks %}
    {# 在这里处理并显示友情链接列表 #}
{% endlinkList %}

friendLinksNow is an array or slice object that contains detailed information of each link. Since it is a list, you need to usefora loop to traverse and display each link:

{% linkList friendLinks %}
    {% if friendLinks %}
        <div>
            <!-- 您可以在这里添加一个标题,例如“合作伙伴”或“友情链接” -->
            <span>友情链接:</span>
            {% for item in friendLinks %}
                {# 循环中,item 代表每一个友情链接对象 #}
                <!-- 在这里构建每个链接的 HTML 结构 -->
            {% endfor %}
        </div>
    {% endif %}
{% endlinkList %}

Inforinside the loop,itemThe variable represents the current looped single friendship link object. Eachitemcontains the following key information that can be called:

  • item.Title: Link display name. For example, "Anqi CMS official website".
  • item.Link: The actual link address. For example, "https://en.anqicms.com.
  • item.Remark: Link remark information, usually not displayed directly on the front end, but may be useful under certain specific requirements.
  • item.Nofollow: A boolean value (0or1), indicates whether the link should be addedrel="nofollow"Property. This is very important for SEO strategy, it can control whether the search engine tracks the link.

Combine these fields, the following example of a complete friend link display code is as follows:

{% linkList friendLinks %}
    {% if friendLinks %}
        <div class="friend-links-section">
            <h3>我们的合作伙伴</h3>
            <ul class="link-list">
                {% for item in friendLinks %}
                    <li>
                        <a href="{{ item.Link }}"
                           {% if item.Nofollow == 1 %} rel="nofollow"{% endif %}
                           target="_blank"
                           title="{{ item.Title }} - {{ item.Remark }}">
                            {{ item.Title }}
                        </a>
                    </li>
                {% endfor %}
            </ul>
        </div>
    {% endif %}
{% endlinkList %}

In this example, we created adivcontainer and used an unordered listulOrganize friend links. Each linkaTags are dynamically boundhref(Link address),title(Hover text) and display text. It is especially important to note that we add dynamically through{% if item.Nofollow == 1 %}judgmentrel="nofollow"Property, and settarget="_blank"Ensure that the link opens in a new window to enhance user experience.

Some advanced usage and details:

  • Multi-site data call:If you are using the multi-site management feature of Anqi CMS and need to display another site's friend link in a template of a site, you can specify it throughsiteIdparameters. For example:{% linkList friendLinks with siteId="2" %}This is very practical in group website or multi-brand website management.
  • Front-end style:The above code only includes the basic HTML structure. To make the link in your website look beautiful, you need to write additional CSS styles to control its layout, font, color, etc.For example, you can set up.friend-links-sectionor.link-listAdd style rules to the class.
  • Backend Management:All of these friend link additions, edits, deletions andTitle/Link/NofollowThe settings of properties are all carried out in the "Function Management" -> "Friend Links" module of Anqi CMS background.Here the management is centralized, the front-end is dynamically called, and the flexible update of content is realized.

BylinkListThe label, Anqi CMS provides an efficient and easy-to-maintain way to manage and display partner website links.This not only helps the website's SEO performance, but also facilitates users in quickly accessing relevant resources, and is an indispensable part of building a perfect website.


Frequently Asked Questions (FAQ)

1. How to add and manage friend links in the Anqi CMS backend?

You can find the "Friend Link" module under the "Function Management" menu in the AnQi CMS backend. Click to enter, and you can easily add new friend links, fill in the name (Title), link address (Link), remarks (Remark) and whether to enable it.nofollowProperty. All changes will be reflected on the front-end immediately.linkListOn the page of the tag.

2.NofollowWhat is the role of the property? When should I use it?

NofollowIt is an HTML attribute used to tell search engines not to follow this link and not to pass 'link juice' to the target website of the link.Its main function is to control which external links your website passes the 'trustworthiness' to.You should consider using it in the following situationsnofollow:

  • Link to a website you do not fully trust.
  • Paid links, advertising links, or sponsored content to avoid being misjudged by search engines as manipulating rankings.
  • Links in user-generated content (such as comment sections, forum posts) to prevent spam links. In友情links, it is usually recommended to use non-core partners or websites you do not want to pass too much weight to.nofollow.

3. If I need to display friendship links in groups,linkListDoes it support tags?

linkListThe tag itself is designed to retrieve all friendship links without directly providing grouping parameters. However, you can agree on a grouping name (such as "Strategic Cooperation", "Industry Partner", etc.) in the "Remark" field when adding friendship links in the background, and then use it on the front endlinkListLabel all the links after using the template'sforLooping and conditional judgment (ifstatements) to group links according toitem.Remarkfields for display. For example, you can build grouping logic like this:

{% linkList friendLinks %}
    {% set strategicPartners = [] %}
    {% set industryPartners = [] %}
    {% for item in friendLinks %}
        {% if item.Remark == '战略合作' %}
            {% set strategicPartners = strategicPartners|add(item) %}
        {% elif item.Remark == '行业伙伴' %}
            {% set industryPartners = industryPartners|add(item) %}
        {% endif %}
    {% endfor %}

    {% if strategicPartners %}
        <h3>战略合作伙伴</h3>
        <ul>
            {% for item in strategicPartners %}
                <li><a href="{{ item.Link }}" target="_blank">{{ item.Title }}</a></li>
            {% endfor %}
        </ul>
    {% endif %}

    {% if industryPartners %}
        <h3>行业合作伙伴</h3>
        <ul>
            {% for item in industryPartners %}
                <li><a href="{{ item.Link }}" target="_blank">{{ item.Title }}</a></li>
            {% endfor %}
        </ul>
    {% endif %}
{% endlinkList %}

This way requires you to manually handle the grouping logic in the template, but it provides great flexibility.