In website operation, friend links play an indispensable role. They not only bring valuable external traffic to the website but also help improve the search engine optimization (SEO) effect, enhance the authority and credibility of the website.For users of AnQiCMS, managing and displaying friend links is a simple and efficient process.This article will introduce in detail how to configure the友情链接 in AnQiCMS backend, as well as how to elegantly present them in the front-end template of your website.
Manage friend links in AnQiCMS backend
Firstly, to display the友情链接 (friendship link) on your website, you need to configure it in the AnQiCMS backend.AnQiCMS provides an intuitive management interface, allowing you to easily add, edit and delete友情链接(friendship links).
Login to your AnQiCMS backend and you can find the "Friend Links" option under the "Function Management" section on the left-hand menu.Click to enter, you will see a list page displaying all the currently configured friendship links.Here, you can click the 'Add New Link' button.
On the interface for adding or editing friend links, you usually need to fill in the following information:
- Link Name:This is usually the text of the friend link, which will be displayed on your website.
- Link address:This is the URL pointed by the friendship link.
- Is
nofollow:This is an important SEO option. If checked, it will addrel="nofollow"Property, tells the search engine not to pass the "weight" to this link, which is very helpful for managing the SEO risk of external links. - Display Order:Used to control the arrangement order of links.
Complete the information entry and save. Your friendship link data has already been stored in the AnQiCMS database.
Display friendship links in the front-end template
After the background data configuration is completed, the next step is how to display these links on the website's front-end template.AnQiCMS powerful template system makes this process very intuitive, it uses syntax similar to Django template engine, making content presentation flexible and simple.
To obtain and display the friend link list in the template, we need to use the built-in AnQiCMS.linkListLabel.This tag is specifically used to retrieve the friend link data configured on the backend.It will return an array (or called slice) object containing all the configured friendship links, and we can simply traverse this array to display each link on the page one by one.
通常,友情链接会放置在网站的页脚(footer)区域,或者单独的“友情链接”页面中。以下是一个在模板中展示友情链接的示例代码片段:
{% linkList friendLinks %}
{% if friendLinks %}
<div class="footer-links">
<h4>友情链接</h4>
<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 break down this piece of code and see how it works:
{% linkList friendLinks %}: This is the core tag, it indicates that AnQiCMS should retrieve all the friend link data and assign these data to a variable namedfriendLinks.{% if friendLinks %}This is a conditional judgment. Good programming practice is to check firstfriendLinksDoes the variable contain actual data.If there is a link, the content within the code block will be executed, which can prevent the display of empty titles or lists when there are no links, keeping the page tidy.<div class="footer-links">...</div>: Here is the HTML structure for wrapping the list of friend links, you can adjust the class name and structure according to your website style.{% for item in friendLinks %}: IffriendLinksThere is data, thisforThe loop will iterate over each link. In each iteration, the current link data will be assigned toitema variable.<li><a href="{{item.Link}}" ...>{{item.Title}}</a></li>In the loop, we useitemAccess each link's attribute using a variable.{{item.Link}}It will output the current friendship link's URL address.{{item.Title}}It will output the current friendship link's display name.
{% if item.Nofollow == 1 %} rel="nofollow"{% endif %}: This is an inline conditional judgment. It checks whether the current friendship link is set in the background.nofollow.item.NofollowThe value is equal to 1 (indicating checked)nofollow), thenrel="nofollow"The attribute will be added to<a>Labels. This allows you to precisely control the SEO properties of each link, very practical.target="_blank"This is a common HTML attribute, usually used for link to friends, indicating that the link will open in a new tab to retain the user's browsing on your website.
If you have enabled the multi-site management feature in AnQiCMS and want to get the friend links of other sites in a specific site template,linkListtags support ansiteIdparameters. For example,{% linkList friendLinks with siteId="2" %}Can obtain the friendship links of the site with ID 2. But in most single-site scenarios, this parameter does not need to be specified.
Summary
Configure the friend links through the friendly management interface of AnQiCMS backend, and combine it with the simple and powerful front-end template.linkListTags, you will find that displaying the website's friend link list is a pleasant and enjoyable experience.This seamless content management approach saves a lot of development time and ensures the flexibility and efficiency of website content management, allowing you to focus better on website content operation and SEO strategy implementation.
Common Questions (FAQ)
Q1: If I do not add any friend links in the AnQiCMS backend, what will the front-end template display?
A1: If no friend links are configured in the backend,{% linkList friendLinks %}the tags you getfriendLinksThe variable will be an empty array. Since the sample code contains{% if friendLinks %}this judgment, so the entire area containing thedivlinks section (including the "links" title andul列表)都不会被渲染,页面上不会显示任何内容,保持了整洁。
Q2: 友情链接中的nofollow属性有什么作用?我应该何时使用它?
A2:nofollow是HTML<a>one of therelThe attribute tells the search engine not to pass the 'PageRank' (page weight) from your website to the linked websites. It is usually used in the following situations:
- Link to a website you do not fully trust.
- Link to the comment section or forum post of user-generated content (to prevent spam links).
- Friendship link or advertising link, when you do not want to be misunderstood as 'selling link weight'.
- If a friendship link website is of poor quality or has little relevance to your topic, use
nofollowCan help you avoid potential SEO risks.
Q3: Can I customize the style and layout of the link exchange?
A3: Of course. The template system of AnQiCMS is very flexible, allowing you to fully control the HTML structure and CSS style of the front-end display. The example code indiv/h4/ul/liandaLabels can all be freely modified according to your design needs. You just need to edit the corresponding template file (usuallyfooter.htmlor pages containing friendship links), and then add the corresponding class name or style according to your website's CSS rules.