Friendship links are a way for websites to recommend each other, not only can they increase the number of external links of the website, but also be beneficial for search engine optimization (SEO), and can also provide visitors with more relevant resource entries to improve the user experience.AnQiCMS provides us with a very convenient function for managing and displaying friend links.
Next, we will together learn how to set up friend links in AnQiCMS and display them on the front page of the website.
1. Manage friend links in AnQiCMS backend
In AnQiCMS, managing friend links is very intuitive. You can find the dedicated function module in the backend interface to add, edit, and manage your friend links.
First, log in to your AnQiCMS backend management system.In the left navigation menu, there will usually be an option named "Function Management" or something similar.Click to enter and you will see the item "Friend Links".
After entering the friend link management page, you can:
- Add a new friend linkClick the "Add" button and enter the "Link Name" (i.e., the text displayed on the website) and the "Link Address" (i.e., the URL the friendship link points to).In addition, you can also fill in "notes" for your own management, and choose whether to add the "nofollow" attribute to the link.The nofollow attribute is very useful for telling search engines not to track this link and not to pass weight, which is a common SEO practice when dealing with some external links.
- Edit existing links: For the friend links that have been added, you can modify their names, addresses, or Nofollow attributes at any time.
- Delete the links that are no longer needed.:Easily delete outdated or non-cooperating friendship links.
AnQiCMS's友情链接管理功能not only supports manual addition, but also provides an API interface, convenient for users who need to perform batch operations or integrate with other systems for management, which greatly improves operational efficiency.
Second, display the friend link on the AnQiCMS front-end page
After completing the background friend link settings, we can then proceed to display these links on the front page of the website. In the AnQiCMS template system, we mainly use a name calledlinkListThe tag to get the friend link data.
1. Find the appropriate template file
Friend links are usually placed in the footer, sidebar, or a dedicated friends link page of a website.You can choose or create a corresponding template file for editing according to your website design.For example, if you want to display friend links at the bottom of all pages, you can do so in the global footer template file (such aspartial/footer.htmlorbase.htmlAdd code in the part that contains the footer.
2. UselinkListLabel to retrieve data
Use in the template file you have selected.linkListTags can easily retrieve all added friendship links. Here is a basic usage example:
{% linkList friendLinks %}
{% if friendLinks %}
<div class="friend-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 %}
Code explanation:
{% linkList friendLinks %}This is the core tag, it will retrieve all the link data from the background and store it in a namedfriendLinksIn the variable. You can replacefriendLinksReplace it with any variable name you like.{% if friendLinks %}: This is a conditional judgment, used to check.friendLinksDoes the variable have data. This can prevent the display of an empty "friend links" area on the page when there are no friend links, keeping the page tidy.<div class="friend-links">...</div>This is an HTML structure, you can add a container and style class to the friend link list according to your own CSS style.{% for item in friendLinks %}This is a loop label, it will iterate overfriendLinksEach friendship link data. In each iteration, the current friendship link data will be assigned toitemVariable.<li>...</li>: Each friendship link is usually displayed as a list item (<li>)<a href="{{ item.Link }}" ...>This is the core part of the link.{{ item.Link }}It will output the current link address, which is the 'link address' you filled in the background.{% if item.Nofollow == 1 %} rel="nofollow"{% endif %}This is a very important condition judgment. It will check the current friendship link'sNofollowattribute is1(which is checked in the background as nofollow). If it is1, then it will be<a>the tag withrel="nofollow"Property.target="_blank"This attribute is usually used to open links in a new tab to avoid visitors leaving your website.{{ item.Title }}This will output the current link name, which is the link name you fill in the background.
3. Style beautification
After you add the above code to the template file, you may also need to beautify the display effect of the friend links through CSS to keep it consistent with the overall style of your website.For example, you can adjust the font size, color, spacing of list items, or arrange them in multiple columns, etc.
3. Notes and tips
- Clear cacheAfter modifying the template file, if the front-end page does not take effect immediately, please remember to clear the AnQiCMS system cache to ensure that the latest template file is loaded.
- Multi-site SupportIf you have enabled the AnQiCMS multi-site management feature and want to call links from other sites on a specific site, you can
linkListthe tag withsiteIdSpecify the site ID to be called. For example:{% linkList friendLinks with siteId="2" %}. - SEO-friendlyFor most link exchanges, especially reciprocal links, it is recommended to check the Nofollow attribute.This helps avoid search engines misjudging as 'buy and sell link' behavior, protecting the SEO health of your website.Only consider not adding Nofollow when you are sure that the link has real recommendation significance for your website and you are willing to pass on weight.
By following these steps, you can easily manage and display friend links on websites built with AnQiCMS, adding more value to your website.
Frequently Asked Questions (FAQ)
Q1: Where can I manage the friendship links?A1: You can find the 'Function Management' in the left navigation bar of the AnQiCMS backend management interface, and then click to enter the 'Friend Links' page for management.
Q2: Why is my friend link not displaying?A2: Please check the following points:
1. **后台是否已添加链接?** 确保您已经在后台添加了友情链接。
2. **模板代码是否正确?** 确认您已将正确的 `linkList` 标签代码放置在前端模板文件中,并且没有语法错误。
3. **是否清除了缓存?** 在修改模板文件后,请务必清除AnQiCMS的系统缓存。
4. **是否有CSS样式覆盖?** 检查CSS文件,看是否有样式将友情链接隐藏或显示为不可见状态。
Q3: How to add a friend link?nofollowAttribute to optimize SEO?A3: When adding or editing a friend link in the AnQiCMS backend, there will be an option for you to choose whether to add properties to the linknofollowAfter checking the option, in the front-end templatelinkListExample code for the{% if item.Nofollow == 1 %} rel="nofollow"{% endif %}tag will automatically generate therel="nofollow"attribute, telling search engines not to follow this link, thereby achieving SEO optimization.