During the operation of a website, friendship links are a common way for websites to recommend each other and share traffic. They not only help to increase the number of external links of the website, but also have a positive effect on SEO optimization, and can also provide more valuable resources for visitors.AnQiCMS (AnQiCMS) provides us with a very convenient function for managing and displaying friendship links.
Management of friendship links: Back-end operation tutorial
In AnQi CMS, managing friend links is very intuitive.First, we need to log in to the website backend, find the "Function Management" item in the left function menu.After clicking, you will see an option named "Friend Links".
Click to enter the friend link management interface, where you can add, edit, or delete friend links on the website. When adding or editing links, you need to fill in the following key information:
- Link Name: This is the name displayed for the friendship link on your website, which is usually the name of the other website.
- Link AddressThis is the complete URL of the other website, make sure it is filled in correctly so that users can jump smoothly.
- Link note(Optional): You can add some internal notes to the link for your own management. This content is usually not displayed on the front end.
- Is nofollowThis is a very important option. If you check 'nofollow', then when the friend link is displayed on your website, it will be automatically added
rel="nofollow"Property.This tells the search engine not to pass on your website's weight to the website linked by the link, which is very useful in SEO strategies and can help you better control the impact of external links on your own website's ranking.Generally, for external links, we would recommend checking this option to maintain the SEO weight of your own website.
Fill in this information and save it. Next, we can display these links on the website page.
Display on the website page: Using template tags
We need to use specific template tags in the Anqi CMS template files to display these links added in the background on the frontend pages of the website (such as the website footer, a dedicated friends links page, etc.)AnQi CMS adopts a syntax similar to the Django template engine, making content display very flexible.
To display the list of friendship links, we can uselinkListthe tag. This tag can help us get all the friendship links set in the background and display them in a loop on the page.
Usually, you would place友情链接 in the public area of the website, such as the footer (footer.html) or a separate page template.
<div class="friendship-links-section">
<h3>友情链接</h3>
<ul>
{% linkList friendLinks %}
{# 检查是否有友情链接,避免在没有链接时显示空标题 #}
{% if friendLinks %}
{% for item in friendLinks %}
<li>
<a href="{{item.Link}}" {% if item.Nofollow == 1 %} rel="nofollow"{% endif %} target="_blank">{{item.Title}}</a>
{% if item.Remark %}
<span class="remark">({{item.Remark}})</span> {# 如果有备注,可以选择显示出来 #}
{% endif %}
</li>
{% endfor %}
{% else %}
<li>暂无友情链接,敬请期待!</li> {# 在没有链接时给用户一个友好的提示 #}
{% endif %}
{% endlinkList %}
</ul>
</div>
Let's take a simple look at this code:
{% 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 replacefriendLinkswith any variable name you like.{% if friendLinks %}This is a simple judgment to ensure that the list content is displayed only when the backend has indeed added friendship links, avoiding an empty title of "Friendship Links" on the page.{% for item in friendLinks %}This is a loop label, it will iterate overfriendLinkseach friendship link data in the variable. In each iteration, the current friendship link data will be assigned toitemVariable.{{item.Link}}This is hereitem.LinkDisplays the current friendship link's URL address.{{item.Title}}This is hereitem.TitleDisplays the current friendship link's name.{% if item.Nofollow == 1 %} rel="nofollow"{% endif %}: This is a conditional judgment, if the background is set to nofollow (i.e.item.NofollowThe value is1),then it will be in<a>the tag withrel="nofollow"Property.target="_blank":This attribute is usually used for friendship links, so that users can open a new window or new tab after clicking on the link, to avoid users leaving your website.{% if item.Remark %}Here is optional, if you have added remarks for the link in the background and want to display them on the front end, you can use this judgment.{% else %} <li>暂无友情链接,敬请期待!</li> {% endif %}:WhenfriendLinksWhen the variable is empty, the page will display this friendly prompt message.
By following these steps, you can easily display the friend link list on a website built with Anqi CMS.Remember to click 'Update Cache' on the backend after modifying the template file to ensure that the latest changes take effect in a timely manner.
Frequently Asked Questions (FAQ)
Q1: What will the front-end page display if no friend links are added to the background?A1: If you follow the code examples provided in the article and there is no friendship link data on the backend, the front-end page will display "No friendship links available, please wait!Such a friendly reminder, and it won't result in an empty list or an error.{% if friendLinks %}judgment.
Q2: Where else can I place the friend links besides the website footer?A2: In addition to the website footer, you can also create a separate "Friend Links" page. Add a single page in the "Page Resources" > "Page Management" of the AnQi CMS backend, and specify a dedicated template file for it, then use it in the template file.linkListTags to display friendship links. This provides users with a centralized entry point to easily browse all partner websites.
Q3: What is the use of the 'nofollow' option? When should I check it?A3: The 'nofollow' option is an important SEO control.Check this means telling the search engine not to pass the "weight" or "trustworthiness" of your website to this external link.nofollowThis helps protect your website's SEO performance, avoiding negative impacts from linking to low-quality websites.