友情链接,作为网站内容生态的一部分,不仅有助于提升搜索引擎排名、优化网站权重,还能为用户提供更多相关资源的导航。In AnQiCMS, managing and displaying friend links is a direct and flexible task, even if you do not have a strong programming background, you can easily achieve it.

Backstage management: easily configure the friend link

In the AnQiCMS admin interface, you will find the link settings located under the "Function Management" menu.Click to enter the "Friend Links" page, where you can centrally manage all external collaboration links.You can conveniently add new friendship links, edit existing link information, or remove links that are no longer cooperative as needed.

When adding or editing a link, the system will prompt you to fill in some key information:

  • Link Name (Title)This is the name displayed on the website for the friendship link.
  • Link address (Link)This is the target URL that the friendship link points to.
  • Link Remark (Remark)):You can add some internal notes to the link for easy management, and these notes are usually not displayed on the front end.
  • NofollowThis is an important SEO option. If this option is checked, the link will includerel="nofollow"Properties, tells the search engine not to pass the weight of the current website to the target link. This is very practical in some advertising collaborations or scenarios where it is not desired to pass the weight to external links.

Complete these settings and the background friendship link data will be ready. Next, let's see how to display them on the website front-end template.

Template Call: With the help oflinkListtags

AnQiCMS provides a user-friendly template tag system for calling various data in front-end templates, including friend links. The core tag used for calling friend links islinkListThis tag can help you get all the friendship link data that is configured in the background.

通常,友情链接会放置在网站的页脚区域,因此您可能会在网站的公共页脚模板文件(例如footer.html或通过includeTags introduced public files) for operations. Here is a typical template code example for displaying friend links:

{% linkList friendLinks %}
    {% if friendLinks %}
    <div class="friendship-links">
        <h3>友情链接</h3>
        <ul>
            {% for item in friendLinks %}
            <li>
                <a href="{{item.Link}}" {% if item.Nofollow == 1 %} rel="nofollow"{% endif %} target="_blank">{{item.Title}}</a>
            </li>
            {% endfor %}
        </ul>
    </div>
    {% endif %}
{% endlinkList %}

Let us parse this code step by step:

  1. {% linkList friendLinks %}This line of code is calling:linkListThe start of a label, it declares a variable namedfriendLinks. AnQiCMS will load all the friendship link data set in the background to this variable.
  2. {% if friendLinks %}This is a simple conditional judgment, used to checkfriendLinksAre there data in the variable. If there is a friend link, the internal code will continue to execute, which helps to avoid displaying an empty friend link area when there is no friend link.
  3. {% for item in friendLinks %}Due tofriendLinksis an array containing multiple friendship link objects, we need to useforto iterate over each link in the array. In each loop,itemrepresents the current friendship link object.
  4. <li>...</li>In the loop, we use<li>tags to wrap each friend link, which is the standard way of writing list items in HTML.
  5. <a href="{{item.Link}}" ...>{{item.Title}}</a>This is the actual link display part.
    • href="{{item.Link}}": Through{{item.Link}}Output the current URL of the friendship link.
    • target="_blank"This is usually added to the friendship link to ensure that the link opens in a new window or tab when clicked, to avoid users leaving the current website.
    • {% if item.Nofollow == 1 %} rel="nofollow"{% endif %}This is a dynamically addedrel="nofollow"fragment of the attribute. If the current link is marked as "Nofollow" in the background, then this attribute will be added to<a>the tag.
    • {{item.Title}}: Through{{item.Title}}Output the display name of the current friendship link.

With such a structure, you can flexibly control the style and display of the friendship link, fully integrated into the overall design of your website.

Multi-site consideration and **practice

AnQiCMS supports multi-site management, if you are operating multiple websites under the same system and want to call their exclusive or shared friend links on specific sites,linkListtags also providesiteIdParameter to specify the site ID to retrieve data.However, under most single-site deployments or default scenarios, it is usually not necessary to manually set this parameter, as the system will automatically identify and retrieve the current site's link exchanges.

On the website operation level, it is recommended that you place the friend links at the footer of the website or other locations that do not disturb the main content but are easy for users to find.The quality and relevance of the友情链接 are far more important than the quantity. Maintaining an appropriate number of links and regularly checking the validity of the links (to prevent dead links) is the key to maintaining the health and SEO performance of the website.Through AnQiCMS, these tasks can become more efficient and convenient.


Common Questions (FAQ)

Q1: If the number of my friendship links is too many, can only a part be displayed?A1:linkListLabels will default to retrieving all friend links configured in the background. If you only want to display a part of them, you can{% for item in friendLinks %}control during the loop. For example, you can use{% if forloop.Counter <= 10 %}To limit to display only the first 10 links, or use the filter function of the AnQiCMS template engine, such as{% for item in friendLinks|slice:":10" %}To cut the first 10 links for circular display.

Q2: Is the display order of the friend links fixed? Can I customize their order on the front end?A2: The display order of friendship links on the front end usually depends on the order in which you add or adjust them in the AnQiCMS backend management interface.The system will output according to the order of the background list.linkListThe tag itself does not provide sorting parameters, so if you need to adjust the display order, do so directly in the backend's友情