Friendship links, as part of the website content ecosystem, not only help to improve search engine rankings and optimize website authority, but also provide users with more related resource navigation.In AnQiCMS, managing and displaying friend links is a direct and flexible task, even if you don't have a strong programming background, you can easily achieve it.
Backend management: easily configure the friend link
On the AnQiCMS backend management interface, you will find the settings for the link of friendship 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 in cooperation as needed.
When adding or editing a link, the system will prompt you to fill in several key pieces of information:
- Link Name (Title): This is the name displayed on the website for the friend link.
- Link AddressThis is the target URL of the友情链接 friendship link
- Remark for Link: You can add some internal notes to the link for easy management, these notes are usually not displayed on the front end.
- NofollowThis is an important SEO option. If this option is checked, the link will include
rel="nofollow"The attribute tells the search engine not to pass the weight of the current website to the target link. This is very useful in some advertising collaborations or in scenarios where you do not want to pass the weight of external links.
After completing these settings, the background friend link data is ready, next let's take a look at how to display them in the website front-end template.
Template call: withlinkListTag
AnQiCMS provides a user-friendly template tag system to call various data in the front-end template, including friend links. The core tag for calling friend links islinkList. This tag can help you get all the friendship link data configured in the background.
Generally, friendship links are placed in the footer area of the website, so you may find them in the public footer template file of the website (such asfooter.htmlOr throughincludePerforming operations on the public file included by tags. 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's parse this code step by step:
{% linkList friendLinks %}This line of code is a call to:linkListThe start of a tag, which declares a variable namedfriendLinks. AnQiCMS will load all the friendship link data set in the background to this variable.{% if friendLinks %}This is a simple conditional judgment, used to checkfriendLinksDoes the variable have data. 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.{% for item in friendLinks %}: Due tofriendLinksis an array containing multiple friendship link objects, we need to useforloop to traverse each link in the array. In each loop,itemthe variable represents the current friendship link object.<li>...</li>In the loop, we use<li>tags to wrap each link, which is the standard practice for list items in HTML.<a href="{{item.Link}}" ...>{{item.Title}}</a>This is the actual display part of the link.href="{{item.Link}}": Pass{{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 the user 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}}: Pass{{item.Title}}Display the current link name.
With such a structure, you can flexibly control the style and display of the link, fully integrating it into the overall design of your website.
consideration and practice across multiple sites
AnQiCMS supports multi-site management, if you are operating multiple websites under the same system and want to call exclusive or shared friend links on specific sites,linkListLabels also providedsiteIdParameters to specify the site ID to retrieve data. However, in most single-site deployments or default scenarios, it is usually unnecessary to manually set this parameter, as the system will automatically identify and retrieve the friendship links of the current site.
On the website operation level, it is recommended that you place the friend link at the footer of the website or in other locations that do not interfere with the main content but are easy for users to find.The quality and relevance of friendship links are more important than quantity. Maintaining a moderate number of links and regularly checking the validity of links (to prevent dead links) is the key to maintaining the health and SEO performance of the website.Through AnQiCMS, all these tasks can be made more efficient and convenient.
Frequently Asked Questions (FAQ)
Q1: Can only a part of my friend links be displayed if there are too many?A1:linkListThe tag will default to retrieving all the friend links configured in the background. If you only want to display a part of them, you can control it in the{% for item in friendLinks %}loop. For example, you can use{% if forloop.Counter <= 10 %}Limit to display only the first 10 links, or use the AnQiCMS template engine filter function, such as{% for item in friendLinks|slice:":10" %}To cut the first 10 links for loop display.
Q2: Is the display order of friend links fixed? Can I customize their order on the frontend?A2: The display order of friend 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. CurrentlylinkListThe label itself does not provide sorting parameters, so if you need to adjust the display order, you can do so directly in the background of the friendship