In website operation, friendship links are one of the important ways to enhance website authority, obtain external traffic, and improve user experience.An easily manageable system that can dynamically display friend links will undoubtedly greatly enhance operational efficiency.The Anqi CMS, as an efficient content management system, provides flexible friend link management functions, allowing you to easily display these valuable external resources in the footer or sidebar of your website.

Friend links management in AnQi CMS

Firstly, the management operation of the友情链接 link is very intuitive.You just need to log in to the backend management interface of Anqi CMS, and you can find the item 'Friend Links' in the 'Function Management' menu on the left.Here, you can conveniently add, edit, or delete friend links.nofollowProperties. These backend settings will directly affect the display effect of the front-end page and SEO strategy.

Dynamic Display: Smart UselinkListTemplate tags

The template system of AnQi CMS is designed to be very flexible, it borrows the syntax of Django template engine, allowing you to dynamically call website data through simple tags. To display the friend link list you have set up in the background on the website frontend, we need to use a special template tag -linkList.

linkListThe function of the tag is to retrieve all the friendship link data you maintain on the back-end and provide it to the template in the form of an iterable list. Its basic usage is{% linkList 变量名 %}。For example, you can define it as{% linkList friendLinks %}, then all the friendship link data will be stored infriendLinksthis variable for your subsequent operations.

Due tofriendLinksis an array object containing multiple link information, you need to useforto iterate over each link item one by one. In the loop, each link item is usually nameditemIt includes various properties of the link, such as:

  • item.Title: The display name of the link.
  • item.Link: The URL address of the link.
  • item.Remark: The remark information of the link (if filled in on the back end).
  • item.NofollowAn English value representing whether the link has been setnofollowproperties.

Next, you can render this information into an HTML structure, generating clickable links. Considering SEO and user experience, we usually addtarget="_blank"Properties, to open links in a new window and, based on the background settings, conditionally addrel="nofollow"properties.

Below is an example of a friendship link list display code in a template:

{% linkList friendLinks %}
{% if friendLinks %} {# 建议先判断是否有友情链接,避免页面出现空白区域 #}
<div class="friend-links-section">
    <h3>友情链接</h3> {# 您可以自定义标题,例如“合作伙伴”、“推荐站点”等 #}
    <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 %}

In this code block:

  • {% linkList friendLinks %}Get friend link data.
  • {% if friendLinks %}JudgmentfriendLinksThe variable has content, ensure that the entire area is displayed only when there is a link.
  • {% for item in friendLinks %}Traverse each friendship link.
  • {{item.Link}}and{{item.Title}}Output the address and name of the link separately.
  • {% if item.Nofollow == 1 %} rel="nofollow"{% endif %}Will dynamically add links based on backend settings.rel="nofollow"Properties, which helps control the weight transfer of the website.
  • target="_blank"Ensure that the link opens in a new tab after clicking to enhance the user's browsing experience.

Place the友情链接 to a specific location on the website

In a website, the footer or sidebar is a common place to display links.The template design of Anqi CMS usually splits these common areas into independent template files.templateFind similar under the 目录partial/footer.htmlorpartial/sidebar.htmlSuch a file.

You need to copy and paste the code snippet provided above into the corresponding template file where you want to display the friend link.Save and refresh the website page, and you will see the friend link list set in the background dynamically displayed on the website.This modular design allows you to manage links centrally and flexibly control their display throughout the website.

If you are using the multi-site management feature of AnQi CMS and want to call the friend link data of other sites in a specific site,linkListtags also providesiteIdyou can achieve this goal with parameters. For example:{% linkList friendLinks with siteId="1" %}Will retrieve the list of friendship links for the site with ID 1.

Through this method, Anqi CMS not only simplifies the maintenance of friend links, but also provides powerful template tag support, making content display more flexible and diverse.


Common Questions (FAQ)

  1. Why is the friend links not displaying in my website footer/sidebar?
    • Please check if the link has been added to the "Function Management" -> "Friend Links" in the security CMS backend. If not, the front-end will not display it naturally.
    • 其次,confirm whether you havelinkListcorrectly pasted the code of the tag to the corresponding position in the website template (for examplepartial/footer.htmlorpartial/sidebar.html). Please check the path of the template file and ensure that the code is complete and correct.
    • If you are using the multi-site feature, please checklinkListwhether the tags are correctly specifiedsiteIdthe parameters, to call the link of the target site.
  2. The properties of the links inrel="nofollow"what role?
    • rel="nofollow"is an HTML attribute used to tell search engines not to follow this link and not to pass the page authority to the target page of the link.In the context of friendship links, it is often used to avoid negative impacts on SEO due to linking to low-quality websites, or when the nature of the link is advertising or user-generated content, in order to comply with the search engine's **practical guidelines**.
  3. Can I display different groups of friend links in different areas of the website?
    • linkListThe label itself does not provide a direct "grouping" parameter in the document. However, you can use the "notes" field to classify tags when adding友情链接 in the background, and then display them on the front end through the template.ifSentences and string judgment (such as{% if item.Remark == "合作伙伴" %}) to filter and display.
    • Another method is to make use of the multi-site feature of Safe CMS. If your friend links are indeed for different topics or purposes, consider managing different sets of friend links under different sites, and throughsiteIdParameter is called at a specific site to access its exclusive friendship link list.