In website operation, friend links (also known as friend links) are an important component for enhancing website authority, increasing external traffic, and promoting interaction between websites.A meticulously maintained list of友情链接, which not only increases the external links of the website and has a positive effect on SEO, but also provides users with more relevant information and improves the user experience.Auto CMS knows its importance and provides an intuitive and friendly backend management interface as well as a convenient template calling method, allowing you to easily obtain and display the friend link list.

Next, we will introduce how to implement this function in Anqi CMS in detail.


一、Backend Management: Easily configure friend links

Firstly, to display the friend links on the website, we need to add them in the backend. The backend operation of Anqi CMS is very intuitive:

  1. Log in to your Anqi CMS backend.
  2. Find and click in the left navigation bar“Function Management”.
  3. Under the Function Management menu, you will see“Friend Links”option, click to enter.

Here, you can add, edit, or delete friend links just like managing other content. Each friend link usually contains the following key information:

  • Link Name (Title)This is the text displayed on the page for the friendship link, for example, 'AnQi CMS Official Website'.
  • Link address (Link)This is the URL of the external website pointed by the friendship link. Please ensure the accuracy of the URL, it is best to includehttp://orhttps://.
  • Remark (Remark):You can add some internal notes to the link for easy management, and these notes are usually not displayed on the front-end page.
  • Whether to setnofollowThis is a very important option. It is recommended to check the box when the link points to an external website, especially when you cannot fully control the quality of the content or the relevance of the website to your own.nofollowThis tells the search engine not to pass the weight of your website to the linked websites, thereby protecting the SEO health of your website.

Through this interface, you can manage your friend links in batches to ensure they are always up to date and of high quality.


Section 2: Front-end display: Flexible invocation of friend link list

When the friendship link data is ready in the background, the next step is to display them on the front-end pages of the website. Anqi CMS provides a concise and efficient template tag for this.linkList.

This tag's design concept is to allow you to obtain the friend link data that has been configured on the back-end with the least amount of code. Its basic usage is as follows:

{% linkList friendLinks %}
    {# 在这里编写循环代码来显示友情链接 #}
{% endlinkList %}

Here,friendLinksis a custom variable name, you can name it according to your preference (for examplelinks/myFriendLinksetc.).linkListthe label will return a list object containing all the friendship link information, you can use aforIterate through them one by one and display them.

linkListThe tag almost does not require additional parameters, it will intelligently fetch all friendship links under the current site. However, if you are using the multi-site management feature and want to fetch friendship links of a specific site, you can use it additionally.siteIdparameters, such as{% linkList friendLinks with siteId="2" %}.

In the loop, each friendship linkitem(You can customize the loop variable name) includes the following fields:

  • item.Title: The name of the friendship link.
  • item.Link: The target URL of the friendship link.
  • item.Remark:Background remark information set (usually not displayed directly).
  • item.Nofollow:A boolean value, if checked in the backgroundnofollow,then this value is1otherwise,0。You can dynamically add it to the front-end based on this value.rel="nofollow"properties.

Friend link list display code example

Now, let's look at an example of how to specifically display a friend link in a template.page/friend-links.html)in it.

{# 假设这是您的模板文件中的某个位置,例如页脚 #}

{% linkList friendLinks %} {# 调用linkList标签,将友情链接数据赋值给friendLinks变量 #}
    {% if friendLinks %} {# 建议先判断friendLinks变量是否存在内容,避免在没有链接时显示空区域 #}
    <div class="friendly-links-section">
        <h3>友情链接</h3> {# 您可以根据需要修改标题 #}
        <ul class="friendly-links-list">
            {% for item in friendLinks %} {# 遍历friendLinks中的每一个友情链接项 #}
            <li>
                <a href="{{ item.Link }}" {# 链接地址 #}
                   {% if item.Nofollow == 1 %} rel="nofollow"{% endif %} {# 根据后台设置的Nofollow属性添加rel #}
                   target="_blank" {# 建议设置为新窗口打开,保留用户在您网站的访问 #}
                   title="{{ item.Title }}{% if item.Remark %} - {{ item.Remark }}{% endif %}"> {# 鼠标悬停时显示链接名称和备注 #}
                    {{ item.Title }} {# 链接的显示名称 #}
                </a>
            </li>
            {% endfor %}
        </ul>
    </div>
    {% endif %}
{% endlinkList %}

Code Explanation:

  • {% linkList friendLinks %}:This is the core tag, it retrieves all friend link data from the database and stores them in a namedfriendLinks.
  • {% if friendLinks %}:This is a conditional judgment, iffriendLinksThe variable is not empty (i.e., the backend has added a friend link), only then render this part of the HTML, to avoid the appearance of an empty "Friendship Links" title or list on the page.
  • {% for item in friendLinks %}Loop through:friendLinksList each friendship link, each time the loop, the data of the current link will be assigned toitema variable.
  • href="{{ item.Link }}": Set the target URL of the link.
  • {% if item.Nofollow == 1 %} rel="nofollow"{% endif %}: This is a key SEO processing. According to the backgroundNofollowField value (1 means yes, 0 means no), dynamically adds linkrel="nofollow"Attribute, tells the search engine not to follow this link, which helps avoid weight loss of your website.
  • target="_blank":通常建议友情链接在新窗口中打开,这样用户在点击外部链接后,您的网站仍然保持打开状态。
  • title="...":为链接添加titleProperty, when the user hovers over the link, a tooltip will be displayed to improve the user experience.
  • {{ item.Title }}:Display the name of the friendship link.

Part three: Practical Applications and Optimization Suggestions

  • Placement selection:Friend links are usually placed in the website's footer area or a separate "Friend Links" page.If your website heavily relies on friendship links for promotion, you can also consider placing a few high-quality links in more prominent positions such as the sidebar.
  • rel="nofollow"Importance:Must pay attention to the background settingsnofollowOption.This is not only part of the SEO strategy, but also a demonstration of being responsible for your website.nofollow.
  • Maintain the relevance and quality of the link:Regularly check your friend links to ensure they are still active and relevant to your website's theme.Remove expired or low-quality links to maintain the health of the friend links list, which is greatly beneficial for the long-term development of the website.

Through the CMS, obtaining and displaying the friend link list is a simple and direct process, allowing you to focus more on the operation of website content rather than complex coding.Follow the above steps and suggestions, your website will be able to better utilize the advantages of friendship links.


Common Questions (FAQ)

Q1: Why didn't the website page show the friend link I added?

A1:Please check the following points:

  1. Is the template called?Does your website template include{% linkList friendLinks %}and subsequentforloop code? If this part of the code is missing, the link will not display.
  2. Link status:Ensure that the friendship link you added in the background is enabled.
  3. Cache issue:If your website has enabled caching or your browser has cached, please try to clear the cache of the Anqi CMS backend (find 'Update Cache' at the bottom of the left menu in the backend), and refresh your browser or access in incognito mode.

English