How to display the friend link list of the website?

Calendar 👁️ 72

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 addedrel="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:

  1. {% 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.
  2. {% 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.
  3. {% 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.
  4. {{item.Link}}This is hereitem.LinkDisplays the current friendship link's URL address.
  5. {{item.Title}}This is hereitem.TitleDisplays the current friendship link's name.
  6. {% 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.
  7. 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.
  8. {% 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.
  9. {% 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.

Related articles

How to add captcha functionality to a message or comment form?

During the operation of the website, the message and comment function is an important channel for enhancing user interaction and collecting feedback.However, the spam comments and malicious submissions that follow often bother website administrators.To effectively prevent these unexpected guests, adding a captcha function to the comment or message form is particularly important.AnQi CMS as a comprehensive content management system provides a convenient way to integrate this security mechanism, helping you maintain a clean, efficient interactive platform.### Preparation Before adding a captcha to your comment or message form

2025-11-09

How to build a custom website contact form?

The website feedback form is an important bridge for interaction between the website and visitors. Whether it is to collect user feedback, customer inquiries, or other interactive needs, a well-designed and functional feedback form is crucial.In Anqi CMS, building a custom message form is much simpler and flexible than you imagine.The built-in 'website message' function provides a powerful basic framework, allowing us to customize deeply according to actual needs. Next, we will discuss in detail how to build a custom message form in Anqi CMS that meets your specific needs.

2025-11-09

How to implement the like function for comments?

User interaction is an important manifestation of website vitality, which can significantly enhance the attractiveness and user stickiness of content.AnQi CMS is a powerful and highly customizable content management system that provides a rich set of features to enhance user engagement.Among them, the comment function is the core battlefield of user communication, and adding a like function to the comments can undoubtedly further stimulate community vitality and allow users to give more direct and positive feedback to high-quality comments.### Overview of AnQi CMS Comment Function AnQi CMS is built-in with a comprehensive comment management system, allowing website visitors to easily comment on articles

2025-11-09

How to integrate the comment submission form and handle user comments?

In modern website operations, user comments are an important way to enhance the interactivity and activity of content.AnQiCMS (AnQiCMS) offers a powerful and flexible comment feature, allowing you to easily integrate a comment submission form on your website and effectively manage user comments.Next, we will explore how to achieve this goal in AnQiCMS together.

2025-11-09

How to implement pagination in the content list?

When managing website content, especially when the amount of content increases, a straightforward and efficient pagination feature becomes particularly important.It not only allows visitors to find the information they need faster, improves the browsing experience, but also avoids performance issues caused by loading too much content on a single page.In Anqi CMS, implementing the pagination function of the content list is flexible and direct, and it can be configured to completion in just a few steps.The Anqi CMS adopts the Django template engine syntax, allowing you to control the display logic of content through clear tags.Add pagination to your content list, we will mainly use two core tags

2025-11-09

How to customize parameter filtering for an article or product list?

In daily website operations, we often encounter such needs: we hope that users can quickly filter out the content they are interested in based on the different attributes of articles or products.For example, on a real estate website, users may want to filter for 'two bedrooms and one living room' 'school district' housing;On a product showcase website, users may want to find 'red' new T-shirts.AnQiCMS (AnQiCMS) provides a powerful and flexible custom parameter function, which can help us easily achieve this refined content filtering

2025-11-09

How to format a timestamp into a readable date in the template (such as: 2023-01-01)?

<ctrl94>thought Here's a thinking process that leads to the article above: 1. **Understand the Goal:** The user wants an article about formatting timestamps in AnQiCMS templates. I need to act as

2025-11-09

How to safely display HTML content retrieved from a database on the frontend without escaping?

In website operation, we often need to display some content with rich formatting, such as mixed text and images on article detail pages, HTML tables on product introduction pages, or interactive codes embedded in custom pages.This content is usually stored in a database and rendered on the front-end page.However, many content management systems (including the familiar AnQiCMS) by default, for website security, will escape the HTML content retrieved from the database, resulting in the front-end displaying the original HTML code rather than the expected effect.

2025-11-09