Friendship links are an indispensable part of website operation, they can not only promote communication and cooperation between websites, but also have a positive effect on SEO optimization.In AnQiCMS, displaying the friend link list is a simple and efficient process, allowing website administrators to easily provide visitors with more valuable external resources.
Backstage management: Configure your friend links
In AnQiCMS, you first need to configure the friend link in the background before it can be displayed on the front page. This process is very intuitive:
In the left menu of the background management interface, you can find the itemfunction managementClick to enter, in one of the sub-functions, you will see theFriendship Linkmanagement entry.
Here, you can easily add, edit, or delete the website's友情链接 (friend links). When adding a友情链接, it is usually necessary to fill in the link'sTitle(which is displayed on the website),Link Addressand you can choose whether to enableNofollowattributes (this is very important for SEO optimization, controlling weight transfer), and you can also add a brief note for the link.
The system also supports API interfaces for adding and deleting friend links, providing convenience for scenarios requiring automated management.
Front-end display: uselinkListTag call
Once the background configuration of the friend link is done, the next step is to display them on the website's front page. AnQiCMS provides a special template taglinkListto help you easily achieve this.
You just need to use the template file that needs to display friendship links (such as the website footer templatefooter.htmlor a dedicated page template) and use the{% linkList friendLinks %}...{% endlinkList %}tag.friendLinksIs a variable name that you can customize, it will carry all the friendship link data obtained from the background, displayed in a list form for looping display.
Each friend link object contains the following key information, you can call it in the template as needed:
Title: The display name of the link.Link: The URL address of the friend link.RemarkLink note information (usually not displayed on the front end).NofollowA boolean value (1 for yes, 0 for no), indicating whether the link hasrel="nofollow"Property.
Here is an example of a template code to display a list of friendship links:
{% linkList friendLinks %}
{% if friendLinks %} {# 检查是否存在友情链接,避免空列表出现 #}
<div class="friendly-links">
<h3>友情链接</h3>
<ul>
{% for item in friendLinks %} {# 循环遍历每个友情链接 #}
<li>
{# 使用item.Link作为链接地址,item.Title作为显示文本 #}
{# 根据item.Nofollow的值,动态添加rel="nofollow"属性 #}
{# target="_blank" 让链接在新窗口打开,提升用户体验 #}
<a href="{{ item.Link }}" {% if item.Nofollow == 1 %}rel="nofollow"{% endif %} target="_blank">{{ item.Title }}</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endlinkList %}
In the code above,{% linkList friendLinks %}The tag is used to retrieve the friendship link list configured in the background and assign it tofriendLinksVariable.{% if friendLinks %}Ensure that only the relevant HTML structure is rendered when there are friend links present, to avoid unnecessary whitespace or titles on the page. Then,{% for item in friendLinks %}Loop through each link, through{{ item.Link }}and{{ item.Title }}Output the link address and display name. Particularly, we have implemented{% if item.Nofollow == 1 %}rel="nofollow"{% endif %}dynamic addition based on background settingsnofollowproperties, and throughtarget="_blank"The link opens in a new window, improving the user experience.
Practical considerations and advanced usage
- SEO-friendliness: As mentioned earlier,
NofollowThe rational use of properties is crucial for SEO. For external links that you do not want to pass weight or cannot fully trust, it is necessary to enable it in the background.NofollowAnd render the property correctly in the template. - Multi-site Support:AnQiCMS supports multi-site management. If you have created multiple sites in the system and need to call the friend links of a specific site, you can
linkListUsed in tagssiteIdparameters, for example{% linkList friendLinks with siteId="2" %}Specify the site ID you want to call. - Page layout and style: Friend links are usually located at the bottom of the website. You can use appropriate CSS styles to beautify the friend links list, making it harmonious with the overall design style of the website.in the example code provided
divandulTags are just structural examples, you can adjust their class names and styles as needed.
By following these steps, you will find that AnQiCMS provides great flexibility and convenience in displaying the friend link list.Whether it is to manage link content or to personalize the display on the front end, AnQiCMS can help you a lot, optimize your website structure, and improve the user experience.
Frequently Asked Questions (FAQ)
Is the friend link supported for image links?Based on
linkListThe fields available for tags (Title,Link,Remark,Nofollow), AnQiCMS default friend link function mainly displays links in text title format.The system does not provide a dedicated picture field for uploading pictures directly as a link.However, when you manage the friendship link in the background, you can set the "title" field of the link to include<img>The HTML code of the tag to achieve the effect of image links, but this is not the original image field supported by the system.How to control the display order of friendship links?The friendship link management interface of AnQiCMS backend usually provides sorting function, you can adjust the display order of links directly in the background.
linkListLabels will be displayed in the order configured on the backend automatically, without the need to set additional sorting parameters in the template. Therefore, if you want to adjust the display order, you just need to go to the backend to operate.How to open friendship links in a new window?To enhance user experience, it is usually recommended to open friend links in a new window to prevent visitors from leaving your website. In the template code, you can
<a>in the tag.target="_blank"This is achieved by the attribute. As shown in the example code in the article, just make sure your<a>tag containstarget="_blank"Just do it.