How to display a list of friend links in the sidebar or footer area of a website?

Calendar 👁️ 69

AanQi CMS provides a set of intuitive and powerful features to help us easily manage website content.Among them, the friendship link is an important part of the external connection of the website, not only helps the website's SEO performance, but also provides users with more valuable jump links.This article will provide a detailed introduction on how to flexibly display the friend links list in the sidebar or footer area of your website.

Manage friend links in the background

Before displaying the friend link on the website front-end, we first need to configure it in the Anqi CMS backend.

To manage the friend link, you can log in to the background, then navigate to the 'Function Management' section on the left menu, and click 'Friend Link'.Here you can see a list containing all the added friend links.Click the 'Add Friend Link' button to create a new link entry.

Each friend link entry usually requires filling in the following key information:

  • Link Name (Title)This is the text displayed on the website for the friendship link, for example, 'AnQi CMS official website'.
  • Link AddressThis is the target URL after clicking the link, be sure to fill in a complete and valid URL, for examplehttps://en.anqicms.com.
  • Remark for LinkThis is an optional field, you can fill it as needed, for example, "partner", "recommended site", etc.This note information can be used in some cases for front-end template logic judgment, so that different types of links can be displayed in different regions.
  • Link nofollow (Nofollow)This is a very important option. Checking this means adding to the friendship linkrel="nofollow"The attribute tells the search engine not to follow this link and pass on the weight. For external links, this is usually a good SEO practice, which can avoid unnecessary weight loss and indicate to the search engine that these links are submitted or sponsored by users, rather than actively recommended by your website.

After filling out this information, save it to add a friendship link to your website backend. You can add any number of friendship links as needed.

Display the friend link list in the template

After configuring the background data, the next step is to display these links on the website's frontend page.Generally, friendly links are placed in the sidebar or footer area, as these are common areas that users often notice when browsing the website.

The template system of AnQi CMS adopts syntax similar to Django template engine, usinglinkListTag to call friend link data.

1. Determine the placement location:

First, you need to determine in which template file to add the code for the友情链接 links.

  • Sidebar: If your website sidebar is an independent template snippet (such as located in thepartial/Under the directorysidebar.htmlOr similar file, then you can add code to that file.
  • Footer: If the footer is a public part of the website, it may be located in the main template file (for examplebash.htmlor in your theme'sfooter.html).

You can refer to the template structure of your current topic to find the appropriate insertion point.

2. UselinkListLabel call data:

After finding the appropriate template file, you can use the following code snippet to display the list of friend links.

{% linkList friendLinks %}
{% if friendLinks %}
<div class="friendly-links-section">
    <h3>友情链接</h3>
    <ul>
    {% 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>({{item.Remark}})</span>
            {% endif %}
        </li>
    {% endfor %}
    </ul>
</div>
{% endif %}
{% endlinkList %}

Let's parse this code line by line:

  • {% linkList friendLinks %}This is the label called to call the friend link list.friendLinksIt is the variable name we define for this list data, and you can access each friendship link through this variable name in subsequent loops.
  • {% if friendLinks %}This is a conditional judgment, it will checkfriendLinksDoes the variable contain any data (i.e., are any friendship links added)? If there are no links, the entire block will not be displayed to avoid blank pages or errors.
  • <div class="friendly-links-section"> ... </div>This is an HTML structure used to wrap the list of friend links. You can add CSS styles to make it correctly layout and beautify on the page.
  • <h3>友情链接</h3>List title, you can modify it according to your actual needs.
  • <ul> ... </ul>Unordered list, each link will be displayed as a list item.
  • {% for item in friendLinks %}This is a loop label, it will iterate overfriendLinksOf each friendship link, and assign the data of the current link toitemVariable.
  • <li> ... </li>: EachitemIt will generate a list item.
  • <a href="{{item.Link}}" ... target="_blank">{{item.Title}}</a>: This is the HTML code of the friendship link.
    • href="{{item.Link}}": Get the address of the friendship link.
    • {% if item.Nofollow == 1 %} rel="nofollow"{% endif %}: This is a conditional judgment, if the background is setNofollowOption 1 (i.e., checked) will be added to the linkrel="nofollow"Property.
    • target="_blank": Opens the link in a new tab to improve user experience.
    • {{item.Title}}: Display the name of the friendship link.
  • {% if item.Remark %} <span>({{item.Remark}})</span> {% endif %}: This code is used to display the remark information of the friendship link, which is also conditional. It will be displayed only when the remark exists.
  • {% endfor %}: EndforLoop.
  • {% endif %}: EndifConditional judgment.
  • {% endlinkList %}: EndlinkList.

By following these steps, you can flexibly display the list of friend links configured on the background in the website's sidebar or footer area.Remember to clear the cache (Update Cache feature in the background) if the website has enabled caching after modifying the template file, to ensure that the changes take effect immediately.

Frequently Asked Questions (FAQ)

How to adjust the display order of friend links?

The display order of the友情链接 links usually depends on their arrangement in the background “Function Management” -> “友情链接”.In AnQi CMS, the background list usually supports drag-and-drop sorting or control through a 'display order' field.If your current template requires a specific sorting method, you can check if there are related settings in the background.If the backend does not have a direct sorting function, links are usually displayed in order of creation time or ID.In this case, to implement more complex sorting (such as by name, weight, etc.), it may be necessary to use front-end JavaScript or CSS'sorderAdjust the properties, but this will increase the complexity of front-end development.

2. Can I display different friend link lists in different areas of the website, such as showing "Partners" in the sidebar and "Recommended Resources" in the footer??

Yes, you can achieve this requirement. BecauselinkListThe tag will default to getting all friendship links, you can cleverly use the "Link Remark (Remark)" field for classification when editing friendship links in the background.For example, note the link in the sidebar as 'Partners', and the link in the footer as 'Recommended Resources'.Then in your template, filter the display through simple conditional judgments:

{# 侧边栏显示“合作伙伴”链接 #}
{% linkList allLinks %}
    {% for item in allLinks %}
        {% if item.Remark == "合作伙伴" %}
            <li><a href="{{item.Link}}" target="_blank">{{item.Title}}</a></li>
        {% endif %}
    {% endfor %}
{% endlinkList %}

{# 页脚显示“推荐资源”链接 #}
{% linkList allLinks %}
    {% for item in allLinks %}
        {% if item.Remark == "推荐资源" %}
            <li><a href="{{item.Link}}" target="_blank">{{item.Title}}</a></li>
        {% endif %}
    {% endfor %}
{% endlinkList %}

3. In the friend linkrel="nofollow"What is the role of this attribute? Should I add this attribute to all friend links?

rel="nofollow"The attribute tells the search engine (such as Baidu, Google) not to pass the weight of your website ("PageRank" or "link juice") to the page pointed to by the link. It indicates that you do not认可 the authority of the link or the link

Related articles

How to implement lazy loading of image content on article detail pages to improve page loading speed?

In today's fast-paced online environment, website loading speed is a key factor in user experience and search engine rankings.For an article detail page containing a large number of images, optimizing the image resources is particularly important.By implementing lazy loading of images, we can significantly improve the initial loading speed of the page, allowing visitors to see the content faster, thereby providing a better experience.The AnQiCMS (AnQiCMS) has fully considered the performance optimization needs of the website design, providing a simple and efficient way to achieve lazy loading of images on article detail pages.###

2025-11-08

How to ensure that the content of the article is rendered correctly as HTML on the front-end page if it uses Markdown format?

In Anqi CMS, master Markdown: Ensure content is elegantly rendered as HTML Markdown, as a lightweight markup language, is increasingly favored by content creators for its simplicity, efficiency, and ease of use.It allows us to focus on the content itself without being distracted by complex layout tools.

2025-11-08

How to get and display the title, content, thumbnail, and publish time on the article or product detail page?

When using Anqi CMS to manage website content, whether it is to publish new articles, update product details, or build list pages, one of the core tasks is to accurately and efficiently display the title, content, thumbnail, and publish time of the content.AnQi CMS provides concise and powerful template tags, making these operations intuitive and easy to understand.This article will introduce in detail how to flexibly obtain and present these key information on your website page, ensuring that the content display is both beautiful and practical.

2025-11-08

How to optimize the Anqi CMS URL structure to improve the search engine's crawling and display effect?

When we manage our own website content, the link (URL) in the address bar is often a detail that is easily overlooked.However, a clear and organized URL structure not only makes it easier for visitors to understand the content of the page, but also lays the foundation for search engines to effectively crawl and display website information.A good URL can not only improve user experience but also directly affect the performance of a website in search results.AnQiCMS was designed with SEO needs in mind from the beginning, providing rich tools and flexible configuration options

2025-11-08

How to display a list of related articles based on the article's Tag (label)?

In a content management system, effectively utilizing tags (Tag) to organize and associate articles is a key factor in improving user experience and the efficiency of content discovery.AnQiCMS provides a powerful and flexible tag feature, allowing us to easily display related content lists based on the tags of the articles. ## Understanding AnQiCMS Tag Function AnQiCMS Tag function is not just for adding keywords to articles, it is more like a way to associate content across categories and models.By adding tags to the article, we can group those with similar themes

2025-11-08

How to implement pagination for article lists, product lists, or Tag lists?

Managing website content, especially when the volume of content grows, how to allow visitors to quickly find the information they need while maintaining smooth page loading is an important issue.AnQiCMS (AnQiCMS) took this into full consideration from the outset of its design, providing a set of intuitive and powerful pagination features that allow your article list, product list, and even Tag list to display in an elegant pagination style.

2025-11-08

How can I display the list of articles under the category page and also show the category's Logo or Banner image at the same time?

Managing and displaying categories in Anqi CMS is a key step in building a well-structured, user-friendly website.The category page not only helps users find the content they are interested in quickly, but also, with the help of carefully designed visual elements such as logos or banner images, it can effectively enhance the brand image and user experience.This article will detail how to implement these functions on the category page of Anqi CMS.

2025-11-08

How to display the global TDK (Title, Keywords, Description) information of the website?

## Optimizing Website Front: Display and Application of TDK Information in AnQi CMS In website operation, TDK (Title, Keywords, Description) is an indispensable basic element for Search Engine Optimization (SEO).They are like the 'business card' of a website, directly telling search engines about the theme, core content, and most important keywords of your page, thereby affecting the ranking and click-through rate in search results.

2025-11-08