In website operation, friend links play an indispensable role.It is not only an effective way for websites to recommend each other and share traffic, but also an important means to enhance the weight and visibility of a website in search engines.However, how to conveniently manage and display these links on a website is a practical problem faced by many website administrators.AnQiCMS as an enterprise-level content management and SEO optimization system, provides an intuitive friend link function and a flexible template calling mechanism, making this process extremely simple.
Friend links management in AnQi CMS
To make the friend link display at the bottom of your website, you first need to configure these links in the AnQiCMS backend system.
- Enter the backend management:Login to your AnQiCMS backend, you can usually find the "Feature Management" menu in the left navigation bar.
- Visit the "Friendly Links:Click the 'Friend Links' submenu under 'Function Management', you will enter the management interface for friend links.
- Add and EditIn this interface, you can easily add new友情链接 (friendship link), or edit, delete existing links. When adding or editing, you need to fill in the following key information:
- Link name:This text will be displayed on your website, used to describe the friendship link.
- Link Address:This is the complete URL address pointed to by the friendship link.
- Link NoteThis is an optional internal note field, convenient for you to manage and identify different links, and it will not be displayed on the website front end.
- NofollowThis is a very important SEO option.Check this option to inform search engines not to pass the weight of your website to the website linked by this link.This is very useful when linking to business partners, advertisements, or websites you do not want to provide SEO benefits for.
Configure all necessary friend links and save your changes.
Call friend links in the footer template of the website.
AnQiCMS uses the Django template engine syntax, which means you can call data from the background configuration through concise tags in the template file.To display the link list at the bottom of the website, you need to make the corresponding changes to the template file.
Confirm the footer template file.:In the template root directory of AnQiCMS (usually
/template/您的模板名称/), find the template file responsible for displaying the website's footer area. Common public footer file paths might bepartial/footer.htmlor directly integrated inbase.htmlautobase.htmlreference it in{% include %}autoInsert
linkListtagsIn the found bottom template file, select a suitable position to display the friend links, such as above the copyright information. Then, insert the following template code:{% linkList friendLinks %} {% if friendLinks %} <div class="footer-friend-links-section"> <h4>友情链接</h4> <ul class="friend-links-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 %}Let's decode the meaning of this code:
{% linkList friendLinks %}This is a built-in template tag that retrieves all the configured friend link data from the AnQiCMS backend and assigns these data as a list to a variable namedfriendLinks.{% if friendLinks %}This conditional judgment statement is very practical. It checksfriendLinksVariable contains any data.If the background has not set any friend links, or the number of links is zero, then the entire friend link area (including the "Friend Links" title and the list) will not be displayed on the website, avoiding blank pages or unnecessary elements.<div class="footer-friend-links-section"> ... </div>and<h4>友情链接</h4>This part is the HTML structure used to wrap the list of friend links and provide a title. You can adjust it according to your website design and style needs.{% for item in friendLinks %}This is a loop label, it will iterate through one by onefriendLinkseach friendship link item in the list. In each loop iteration, all the information of the current link will be temporarily assigned toitema variable.<li> ... </li>:Each friendship link will be wrapped in a list item.<li>.<a href="{{item.Link}}" {% if item.Nofollow == 1 %} rel="nofollow"{% endif %} target="_blank">{{item.Title}}</a>:This is the core code for displaying a single friendship link.href="{{item.Link}}":Dynamically output the URL address of the friendship link.{{item.Title}}:Dynamically outputs the name of the友情链接..{% if item.Nofollow == 1 %} rel="nofollow"{% endif %}:This is an important conditional judgment. If the backend has checked the “Nofollow” option for this link (indicating)item.Nofollowhas a value of 1), then<a>Labels will be automatically addedrel="nofollow"properties.target="_blank"This is usually a good practice, to open friendship links in a new window or new tab, so that users can access the friendship links without leaving your current website.
Save and View Effects
Complete the template file modification and then save the file.If your AnQiCMS is deployed in a production environment and page caching is enabled, you may need to clear the website cache (which can be found in the "Update Cache" feature of the AnQiCMS backend, or through server operations) to make the changes take effect.Refresh your website homepage, and you should be able to see the newly added friend links list at the bottom.
Summary
Common Questions (FAQ)
1. Q: Can I control the number of displayed friend links, such as showing only 5 or 10?
Answer:linkListThe tag itself does not provide directlimitParameter to limit the number of items obtained. If you want to control the number of displayed items, you can use the loop variable in the template.{% for item in friendLinks %}In the loop, using the loop variable (such asforloop.Counter)Perform a conditional judgment. For example, if you only want to display the first 5 links, you can modify it like this:{% for item in friendLinks %}
{% if forloop.Counter <= 5 %}
<li>...</li>
{% endif %}
{% endfor %}or directly inforadd it in the loopsliceuse a filter to truncate the array:{% for item in friendLinks|slice:":5" %}.
2. Ask: I hope my friendship links can be displayed in groups, such as 'Partners' and 'Industry Media', does AnQiCMS support this?
Answer:linkListLabels will fetch all the friendship links from the background, without built-in grouping features.To implement grouped display, a common method is to add a category mark (such as "Partners" or "Industry Media") for each link by using the "Link Remarks" field when adding friend links in the background.linkListTags, and according toitem.RemarkThe value is used for conditional judgment to filter and display:{% for item in friendLinks %}
{% if item.Remark == "合作伙伴" %}
<li>...</li>
{% endif %}
{% endfor %}You can also usefilterfilter combined withcontaina filter for more flexible filtering effects.
3. Ask: What is the specific function of the 'Nofollow' attribute in the友情链接? When should I check it?
Answer: 'Nofollow' is HTML<a>A tag attribute used to indicate to search engines not to follow the link and not to assign any "weight"