During the operation of our website, friendship links not only help increase the number of visits, but are also an indispensable part of SEO optimization.A healthy friendship link ecosystem, which can effectively pass on weight and enhance the authority of the website.linkList.

This article will introduce how to use in detaillinkListThe tag displays the friend link list on your AnqiCMS website.

Get to knowlinkListTag

linkListThe tag is a powerful and easy-to-use tag provided by the AnqiCMS template engine, specially used to retrieve and display the friendship links you set from the website background.By it, you can easily integrate the website's friend link into any position on the page, such as the footer, sidebar, or a dedicated friend link page.

Basic usage method

UselinkListTo get the list of friend links directly, you need to place the tag in the template file at the position where you want the friend links to appear, and配合一个forA loop to traverse each link item.

The basic calling method is as follows:

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

In this code block,friendLinksIs the variable name you customize for the friend link list. AnqiCMS will store all the friend link data obtained in this variable for subsequent use.forCyclic use.{% linkList %}and{% endlinkList %}The tag must appear in pairs, enclosing the area where you want to display the friend link content.

Tag parameters:siteId

linkListThe tag supports an optional parameter:siteId.

  • siteIdThis parameter is usually not required to be manually set. If you have created multiple sites in the AnqiCMS background management and want to call the friendship link data of other sites in the template of the current site, you can specifysiteIdTo implement. For example,siteId="2"The link of the site with ID 2 will be called. In most single-site operations, you can ignore this parameter, and the system will default to fetching the link of the current site.

Loop variable and available fields

OncelinkListLabel gets the friend link data and assigns it tofriendLinksVariable, you can then pass throughforLoop to process each link item one by one. Inside the loop, each link item is usually represented byitema variable (you can customize the name of this loop variable), anditemContains the following practical fields:

  • item.Title: The name or anchor text of the friendship link.
  • item.Link: The actual jump address of the friendship link.
  • item.Remark: Note information for the友情链接 link, usually used in backend management, may not be displayed on the front end.
  • item.Nofollow: A boolean value (or number 1/0), indicating whether the link should be addedrel="nofollow"Property.NofollowThe attribute tells the search engine not to follow this link, it is usually used for external links to avoid passing weight or handling ad links.

Actual application example

Here is a more complete example showing how to elegantly display friendship links on a webpage and add properties dynamically according toNofollowdynamic propertiesrel="nofollow":

<div class="footer-links">
    {% linkList friendLinks %}
        {% if friendLinks %}
            <h3>友情链接</h3>
            <ul class="friend-link-list">
                {% for item in friendLinks %}
                <li>
                    <a href="{{ item.Link }}"
                       {% if item.Nofollow == 1 %}rel="nofollow"{% endif %}
                       target="_blank"
                       title="{{ item.Title }}">{{ item.Title }}</a>
                </li>
                {% endfor %}
            </ul>
        {% else %}
            <p>暂无友情链接。</p>
        {% endif %}
    {% endlinkList %}
</div>

In this example:

  1. Firstly, we use{% linkList friendLinks %}tags to get all the friendship links.
  2. {% if friendLinks %}Ensure that the title and list of 'Friend Links' are rendered only when there are existing friend links, to avoid displaying an empty title.
  3. {% for item in friendLinks %}Iterate through each friend link.
  4. In<a>Tagged,href="{{ item.Link }}"Set the link address,target="_blank"Open link in a new window.
  5. {% if item.Nofollow == 1 %}rel="nofollow"{% endif %}This line is crucial, it is based on the settingsNofollowDynamically adds properties to the linkrel="nofollow".
  6. title="{{ item.Title }}"Adds a tooltip text on hover to the link{{ item.Title }}Displays the link name.
  7. If there are no friendship links, then a prompt 'No friendship links available' will be displayed.

Back-end management friendship link

Managing friend links in AnqiCMS is also very intuitive.You can find the "Friend Link Management" option under the "Function Management" menu in the background.Here, you can add new友情链接, edit the information of existing links (including link name, URL, and whether to set Nofollow), and delete links that are no longer needed.Flexible backend management ensures that you can update and maintain the website's friend links at any time.

BylinkListLabel, AnqiCMS provides website administrators with an efficient and flexible way to integrate and display friend links, which not only beautifies the website layout but also adds strength to the website's SEO performance.


Frequently Asked Questions (FAQ)

How to add and manage friend links on the AnqiCMS backend?You can find the "Function Management" menu in the left navigation bar of the AnqiCMS background management interface, click to enter, and then find the "Friend Link Management" option in it.On this page, you can add, edit, or delete the website's friend links.

What is the use of the 'Nofollow' attribute in friend links? How should I use it? rel="nofollow"The attribute is an HTML tag attribute that tells the search engine not to follow the link and not to pass any "weight" from your website to the linked website.This is typically used in the following situations: linking to untrusted content, paid advertisement links, user-generated content (such as links in comments), or external links you do not want search engines to crawl or index.NofollowProperty.

3.linkListCan the label display friendship links of a specific category or group? linkListThe tag will retrieve all the added friendship links from the background “Friendship Link Management”.Currently, it does not have built-in parameters to directly support displaying friend links by category or grouping.item.Remarkfield) to filter and display links belonging to a specific group.