As an experienced website operations expert, I am well aware of the importance of friendship links in the website ecosystem.They are not only potential entry points for external traffic, but also an indispensable part of enhancing the authority of the website and improving search engine rankings (SEO).AnQiCMS as a content management system that highly focuses on SEO and user experience naturally provides an intuitive and powerful management tool for link exchange.linkList—— basic usage.
When you need to display friendship links on the website front-end, AnQiCMS provides a feature namedlinkListThe dedicated template tag.The core function of this tag is to pass all the carefully configured friendship link data from the backend to the frontend template in a form that is easy to handle, allowing you to flexibly control their display methods.
linkListCore functions and basic usage of tags
linkListTags will collect the background friend link data into a variable, usually we name itfriendLinks, but this is not mandatory. You can also name it according to your personal preference, for examplelinksorexternalLinksThe friendship link is usually displayed in a list form, so we need to use the loop structure of the template engine to present each piece of data one by one.
Let's understand through a typical code example.linkListThe practical application of 【en】:
{% linkList friendLinks %}
{% if friendLinks %}
<div class="footer-links">
<h3>友情链接</h3>
<ul class="friend-list">
{% 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 %}
This code first retrieves the latest 5 articles by{% linkList friendLinks %}Label to obtain friend link data and assign it to 【en】:friendLinksA subsequent 【en】:{% if friendLinks %}Ensure that the relevant HTML structure is rendered only when there is a friend link, to avoid empty blocks on the page.
We use it inside the loop body,{% for item in friendLinks %}Visit each friendship link. Here,itemrepresents the single friendship link object in the current loop, which includes the following keywords that you can call in the template:
item.TitleThis is the display name of the friendship link, for example 'AnQi CMS Official Website' or 'Excellent Blog'. This is the text of the link that users see on the website.item.LinkThis points to the full URL address of the friendship link, for examplehttps://en.anqicms.com/When the user clicks the link, they will be redirected to this address.item.RemarkThis is the note information for the friendship link, which is usually not directly displayed on the front-end, but it can help you better identify and classify links in the back-end management.item.NofollowThis is a very important SEO attribute. Whenitem.Nofollowhas a value of1it means that this link is set asrel="nofollow", telling search engines not to track this link and not to pass any weight. If the value is0or does not exist, it means this is a regular link. We巧妙地利用condition judgment skillfully in the above examples{% if item.Nofollow == 1 %}to dynamically addrel="nofollow"properties.
Flexible parameters: Multi-site call
In most cases,linkListThe label meets your needs without additional parameters.It will automatically retrieve all the友情链接 configured in the background of the current site.siteIdSpecify the target site ID using parameters. For example,{% linkList friendLinks with siteId="2" %}you will get the friend link list of the site with ID 2. This provides great flexibility for multi-site operations.
Seamless connection between background management and front-end display
All these links, adding, editing, and management are done in the 'Feature Management' menu under the 'Friend Links' module of AnQiCMS. Here you can set the title, URL, remarks, and whether to add for each link.nofollowProperties. The intuitive operation on the back end ensures that you can easily maintain these important external resources, while the front end.linkListtags are responsible for securely and efficiently presenting this data on your website.
Rationally utilizelinkListTags can not only effectively improve the SEO performance of a website but also provide users with more valuable external resources, enhancing the authority and user stickiness of the website.Place it in the website footer, sidebar, or a dedicated 'Friends Links' page, and it can effectively serve its purpose.By using the powerful template engine of AnQiCMS, you can customize a unique display effect for the link exchange according to the overall design style of the website.
Common Questions (FAQ)
1. How to add and manage友情链接 (friend links) in the AnQiCMS backend?
You can find the 'Function Management' menu by navigating through the left-hand navigation bar after logging into the AnQiCMS backend. Click on the 'Friend Links' option in the submenu. After entering the friend links management page, you can click the 'Add Friend Link' button to create a new link, or edit, delete existing links, and set the title, URL, notes, and usage status for each link.rel="nofollow"properties.
2. Why isn't my friend link showing?rel="nofollow"properties?
Is my friend link showing?rel="nofollow"Properties, depending on whether you checked the corresponding options when editing this link in the AnQiCMS backend. At the template level,linkListTags provideitem.Nofollowfield, only when the value of this field is1(indicating that nofollow is selected) when you need to make a conditional judgment in the template code (such as{% if item.Nofollow == 1 %} rel="nofollow"{% endif %}The attribute is output dynamically. If the backend is not checked or the corresponding judgment logic is not written in the template,nofollowthe attribute will not be displayed.
3. Can I display the website logo or icon in the友情链接 list?
linkListThe default fields provided by the tags includeTitle/Link/RemarkandNofollowThere is no direct field provided for Logo or icon. If you want to display a Logo, there are usually two implementation methods:
a. **在链接标题中包含 `<img>` 标签:** 在后台添加友情链接时,直接将Logo的 `<img>` 标签代码写入“链接名称”字段。例如:`<img src="/path/to/logo.png" alt="AnQiCMS"> AnQiCMS官网`。这种方式简单直接,但后台管理界面可能显示为HTML代码。
b. **利用备注字段或自定义字段:** 在后台友情链接的“备注”字段中填写Logo的URL,或者如果AnQiCMS支持为友情链接模型添加自定义字段,您可以添加一个专门用于Logo URL的字段。然后,在前端模板中,您可以解析 `item.Remark` 或自定义字段的内容来显示图片。这需要一些额外的模板处理逻辑。