In website operation, friendship links (also known as friend links) are an important component for improving website authority, increasing external traffic, and promoting interaction between websites.A well-maintained list of friendship links, 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.AnQi CMS knows its importance, provides an intuitive and friendly backend management interface and convenient template calling method, allowing you to easily obtain and display the list of友情链接 links.

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


One, backend management: easily configure the link

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

  1. Log in to your Anqi CMS backend.
  2. Find and click in the left navigation bar“Function Management”.
  3. You will see in the feature management menu“Friendship links”Options, 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友情链接, for example, 'AnQi CMS official website'.
  • Link AddressThis is the URL of the external website linked by the friendship link. Please ensure the accuracy of the URL, it is best to includehttp://orhttps://.
  • Remark: You can add some internal notes to the link for easy management, these notes are usually not displayed on the front-end page.
  • Whether to setnofollowThis is a very important option. It is recommended to check when the link points to an external website, especially when you cannot fully control the quality of the content or its relevance to your websitenofollowThis 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 batch manage your friend links to ensure they always remain up-to-date and of high quality.


II. 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 page of the website. Anqi CMS provides a simple and efficient template tag for this:linkList.

The design concept of this tag is to allow you to get the friendship link data configured on the background 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 tag will return a list object containing all friendship link information, you can use a loop to iterate over them one by one.forTo display them one by one.

linkListThe tag usually does not require any additional parameters, it will intelligently obtain all the friendship links under the current site. However, if you are using the multi-site management feature and want to obtain friendship links of a specific site, you can use it additionallysiteIdparameters, for example{% linkList friendLinks with siteId="2" %}.

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

  • item.Title: The name of the friendship link.
  • item.Link: The target URL of the friendship link.
  • item.Remark: Note set by the background (usually not displayed directly).
  • item.Nofollow: A boolean value, if checked in the backgroundnofollow, then this value is1Otherwise0. You can dynamically add this value on the front end.rel="nofollow"Property.

Friend link list display code example

Now, let's look at an example code of how to display the friendship link in the template.This is usually placed in the footer (footer.html) or a dedicated page for links (for examplepage/friend-links.html).

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

{% 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 a core tag, it retrieves all friend link data from the database and stores it in a namedfriendLinks.
  • {% if friendLinks %}: This is a conditional judgment, iffriendLinksThe variable is not empty (i.e., there are friend links added in the background), so this part of the HTML is rendered to avoid an empty 'Friend Links' title or list on the page.
  • {% for item in friendLinks %}: Loop through.friendLinksEach friendship link in the list, when the loop runs, the data of the current link will be assigned toitemVariable.
  • 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 backgroundNofollowThe value (1 means yes, 0 means no), dynamically adds linksrel="nofollow"Attribute, tells the search engine not to follow this link, which helps avoid weight loss on your website.
  • target="_blank"It is usually recommended to open友情链接 in a new window so that the user's website remains open after clicking on an external link.
  • title="..."To add a link,titleAttribute, when the user hovers over the link, a tooltip will be displayed to enhance user experience.
  • {{ item.Title }}: Display the name of the friendship link.

3. Practical Applications and Optimization Suggestions

  • Select the placement location:Friendship links are usually placed in the footer area of a website or a separate "Friendship Links" page.If your website is heavily dependent on link building for promotion, you can also consider placing a few high-quality links in more prominent positions such as the sidebar.
  • rel="nofollow"The importance of:Pay special attention to the backend settings.nofollowOptions. This is not only part of the SEO strategy, but also a sign of being responsible for your website.When linking to external websites, especially when you cannot fully control the quality of the content on the site, or when the relevance of the other site to your topic is low, it is recommended to check the boxnofollow.
  • 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 invalid 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.

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


Frequently Asked Questions (FAQ)

Q1: Why did I add a friend link but it did not display on the website page?

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:Make sure the friend link you added in the background is enabled.
  3. Cache problem:If your website has cache enabled or the browser has cache, please try to clear the AnQi CMS backend cache (find "Update Cache" at the bottom of the left menu in the backend), and refresh the browser or access in incognito mode.

Friendship