In website operation, friendship links (also known as cooperative website links) play an important role.They can not only bring additional traffic to the website, but also help improve search engine optimization (SEO) performance, enhance the authority and user trust of the website.linkListLabel.
Flexible display of cooperative websites:linkListThe purpose and basic principle of the label
linkListThe label is a powerful tool designed by AnQi CMS specifically for handling friend links.It can dynamically fetch all the link information of the cooperative websites you have pre-configured from the background database and display it at any position on the website front end.This means that once you update the friendship link in the background, the front-end page can display the latest content without manually modifying the code, greatly improving content management efficiency.
UselinkListTags, you can easily build a friend links block, whether it is placed in the website footer, sidebar, or a dedicated "Partners" page.It returns a list object containing all the friendship link information, and you can iterate through it one by one as you would with a regular data list.
How to uselinkListHow to display friend links on the website
To call and display friend links in your 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 data for the links. For example, we can name itfriendLinks:
{% linkList friendLinks %}
{# 在这里处理并显示友情链接列表 #}
{% endlinkList %}
friendLinksNow it is an array or slice object, which contains detailed information of each friendship link. Since it is a list, you need to usefora loop to iterate 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 callable key information:
item.Title: 链接的显示名称。例如,“安企CMS官网”。item.Link: 链接的实际网址。例如,“https://en.anqicms.com.item.Remark: Linked note information, usually not directly displayed on the front end, but may be useful under certain specific requirements.item.NofollowA boolean value(0or1),indicating whether the link should be addedrel="nofollow"Properties. This is very important for SEO strategies, as it can control whether the search engine tracks the link.
Combine these fields, the following is a complete example of a friendship link display code:
{% 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.aTags are dynamically bound.href(Link address,)title(Hover text) and display text. It is especially important to note that we add dynamically through judgments.{% if item.Nofollow == 1 %}dynamically add through judgments.rel="nofollow"Property, and settarget="_blank"Ensure that the link opens in a new window to enhance the 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 links in a template of a site, you can specify it through
siteIdparameters. For example:{% linkList friendLinks with siteId="2" %}This is very practical in group website or multi-brand website management. - Front-end styles:The code above only includes the basic HTML structure.To make the友情链接 (friendship link) look beautiful on your website, you need to write additional CSS styles to control its layout, font, color, and other aspects.
.friend-links-sectionor.link-listAdd style rules for the class. - Back-end management:All these additions, edits, and deletions of friendly links,
Title/Link/NofollowThe settings of properties such as this are performed in the "Function Management" -u003e "Friend Links" module of the Anqi CMS backend.Here is the centralized management, dynamic front-end calling, and flexible content update achieved.
PasslinkListTags, 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 comprehensive website.
Common Questions (FAQ)
1. How to add and manage友情链接 in AnQi CMS backend?
You can find the 'Friend Links' module under the 'Function Management' menu in the Anqi CMS backend. Click to enter, and you can conveniently add new friend links, fill in their name (Title), link address (Link), remarks (Remark), and whether to enable it.nofollowProperty. All changes will be immediately reflected on the front-end that uses itlinkListon the page of the tag.
2.Nofollow属性有什么作用?我应该在什么时候使用它?
NofollowIt is an HTML attribute used to tell search engines not to track 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 will pass on the "trustworthiness".nofollow:
- 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 generated by users in content (such as comment sections, forum posts), to prevent spam links.
In friend links, it is usually recommended to use sites that are not core partners or those you do not want to pass too much weight to.
nofollow.
3. If I need to group display the friend links,linkListdoes the tag support?
linkListThe label itself is designed to retrieve all friendship links without providing direct 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 frontend.linkListLabel all links after obtaining them, and use templates toforloop and conditional judgments (ifto group links according toitem.Remarkfields for display.
For example, you can build group 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 method requires you to manually handle the grouping logic in the template, but provides great flexibility.