What data structure does the variable `friendLinks` represent in `{% linkList friendLinks %}`?

Calendar 👁️ 82

As an experienced website operations expert, I fully understand the key role of an efficient content management system in the success of a website.AnQiCMS (AnQiCMS) provides great convenience for operators with its flexible template engine and rich features.Today, let's delve into a commonly used and key tag in the AnQiCMS template:{% linkList friendLinks %}Especially among themfriendLinksThe data structure represented by the variable, and how to make full use of it to optimize your website.

DecryptionfriendLinksWhat kind of data structure is it?

In Anqi CMS template design, when you see{% linkList friendLinks %}such a tag,friendLinksit is not just a simple string or a single link, but alist (or array) objectIt carries all the friendship link entries configured in the website background, and each entry itself is a structured data block containing the detailed information of the friendship link.

Imagine that in the "Friendship Link Management" module of your website backend, you may have added dozens or even hundreds of friendship links.friendLinksThis variable is equivalent to packaging all visible links on the backend management interface into an ordered collection for front-end templates to call and display as needed.Since it is a list, this means you need to traverse it in a loop to access and render each link one by one.

friendLinksCarrying information in each element.

SincefriendLinksIs a list object, then what specific information does each 'friend link' entry contain? According to the Anqi CMS template tag document, each element in the list can be understood as an object containing the following key fields (or a struct in Go language):

  1. Title(Link Name)This field stores the display text of the friendship link, which is the clickable link text that users see on your website.For example, 'Anqi CMS official website', 'Some technology blog' and so on.It is usually a string type.

  2. Link(Link address)This field saves the actual URL address of the friendship link.When the user clicks the link, the browser will jump to this address.This is also a string type, and is usually a complete URL, such ashttps://en.anqicms.com.

  3. Remark(Link Description)This is an optional field, used to store additional information or remarks about the friendship link.This note may not be displayed directly on the front page, but it can be used for background administrators to classify or record links. Of course, if you need it, you can also display it in the template.

  4. Nofollow(Whether to Add)nofollowAttribute): This is a very important SEO-related field. It is usually a boolean value (or an equivalent number, such as0Indicatesfalse,1IndicatestrueWhenNofollowWith1It means that the friendship link should be added during renderingrel="nofollow"The attribute tells the search engine crawler not to follow this link and not to pass the weight of your website to the target website, which is crucial for managing the SEO impact of external links.

Once you understand these fields, you can clearly know how to proceed fromfriendLinksExtract the required information from the list and present it in your website template.

Practice session: How to use in the templatefriendLinks

MasteredfriendLinksAfter the data structure, how do you show this information in the AnQiCMS template? Since it is a list, we will naturally use the template engine'sforLoop tags. The following is a typical template code example that shows how to traversefriendLinksAnd output each friendship link:

{% linkList friendLinks %}
{% if friendLinks %} {# 建议先判断friendLinks是否存在或不为空 #}
<div class="footer-links">
    <h3>友情链接</h3>
    <ul class="friend-links-list">
        {% for item in friendLinks %} {# 遍历friendLinks列表,每个链接项命名为item #}
        <li>
            <a href="{{ item.Link }}"
               {% if item.Nofollow == 1 %} rel="nofollow"{% endif %} {# 根据Nofollow字段动态添加rel属性 #}
               target="_blank" {# 通常友情链接会设置为新窗口打开 #}
               title="{{ item.Remark|default:item.Title }}" {# 如果Remark存在则作为title,否则使用Title #}>
                {{ item.Title }}
            </a>
        </li>
        {% endfor %}
    </ul>
</div>
{% endif %}
{% endlinkList %}

In this code block:

  • {% linkList friendLinks %}The tag first called the background friendship link data and assigned it tofriendLinksVariable.
  • {% if friendLinks %}It is a good practice to judgefriendLinkswhether it is empty. If there is no configuration of friendship links, the entire block will not be rendered, avoiding unnecessary blank spaces or errors on the page.
  • {% for item in friendLinks %}Looped throughfriendLinksthe list. In each iteration, the current friendship link entry is assigned toitemthis temporary variable.
  • Byitem.Link/item.Title/item.Remarkanditem.NofollowWe can easily access the specific attributes of each link entry.
  • {% if item.Nofollow == 1 %} rel="nofollow"{% endif %}This line of code is particularly important, it dynamically adds attributes to the link based on the backend configurationrel="nofollow"which is crucial for maintaining the SEO health of the website
  • title="{{ item.Remark|default:item.Title }}"and handles it elegantlyRemarkThe field may be empty. If the note does not exist, use the link title as a prompt.

Manage and call friend links in this structured way, not only makes your template code neat and easy to understand, but also greatly improves the efficiency of content updates and maintenance.

Why should we use structured data to manage友情链接 links?

Our company's CMS adopts this structured method (objects in a list) to manage友情链接 links, which has profound operational and technical considerations:

  1. Content and presentation separation: Friend link data (such as URL, title, whether Nofollow) is stored in the background, and how to display (color, font, layout) is controlled by the front-end template.This separation allows website design and content management to be carried out independently, without affecting each other.
  2. convenient for batch management and expansion: When all links are stored in a uniform structure, the backend operations of adding, deleting, modifying, and querying become very efficient.In the future, if it is necessary to add new attributes to the friendship link (such as the link's logo image, category, etc.), it is only necessary to add the corresponding fields in the data structure without modifying the existing logic.
  3. beneficial for SEO strategy implementation:NofollowThe built-in support for attributes allows operation personnel to finely control which links should pass weight and which should not, effectively avoiding SEO negative impacts caused by the abuse of friend links.
  4. Enhance the reusability and maintainability of the templateOnce defined:friendLinksThe data structure, any developer who follows the AnQiCMS template syntax can quickly understand and make template modifications or customizations, reducing the cost of learning and maintenance difficulty.

In short,{% linkList friendLinks %}

Related articles

How to correctly call the friend link list on the homepage or specified page of AnQiCMS website?

As an experienced website operations expert, I am well aware of the importance of friendship links to the website.They are not only effective means to improve the performance of search engine optimization (SEO), but also a way to expand cooperation and increase the authority of the website.In AnQiCMS (AnQi CMS), managing and calling friend links is a very intuitive and flexible process that can help you easily display these valuable external resources on the homepage or other specified pages.### Management and value of friendship links in AnQiCMS Before starting the front-end display

2025-11-06

What is the basic usage method of the AnQiCMS friendship link tag (linkList)?

As an experienced website operations expert, I fully understand the importance of friendship links in the website ecosystem.They are not only potential entry points for external traffic, but also an indispensable part for enhancing the authority of the website and improving search engine rankings (SEO).AnQiCMS is a content management system highly focused on SEO and user experience, naturally providing an intuitive and powerful management tool for link exchanges.Today, let's delve into the basic usage of the AnQiCMS friendship link tag——`linkList`.

2025-11-06

How to optimize the performance of multilingual sites using Go language features?

AnQiCMS as an enterprise-level content management system built with Go language, has shown unique advantages in optimizing the performance of multilingual websites.For many companies or content operation teams that hope to expand into the international market, the performance of multilingual websites is crucial.A slow-loading, unresponsive multilingual site not only affects user experience but may also lead to the loss of potential customers and a decline in search engine rankings.AnQi CMS precisely grasps this core pain point, utilizing the many features of the Go language to provide solid technical support for the smooth operation of multilingual sites

2025-11-06

How does AnQiCMS's multilingual support enhance the website experience for global users?

How does the multilingual support of AnQiCMS enhance the website experience for global users?In today's rapidly developing digital age, enterprises and content creators are increasingly aware of the importance of the global market.A website that can cross language barriers, not only can reach a wider user base, but is also the key to building an international brand image and enhancing user trust.AnQiCMS (AnQiCMS) is well-versed in this, and its built-in powerful multilingual support feature is designed to solve this pain point, aiming to provide global users with seamless, localized website experiences

2025-11-06

How to get the text name (Title) of each link when looping through the friendship link tags?

As an experienced website operations expert, I know that how to flexibly use template tags to display content in a high-efficiency content management system like AnQiCMS is the key to improving website operation efficiency.Friend links are an indispensable part of website external communication and SEO optimization, and their dynamic display often requires us to accurately obtain the text names of each link from the loop output.Today, let's delve deeply into how to elegantly implement this feature in AnQiCMS.

2025-11-06

How to extract the URL address (Link) from the friendship link tag?

## Unveiling AnQi CMS friendship link: Practical guide on how to efficiently obtain and use website link URLIn AnQi CMS, such an efficient and customizable Go language content management system, how to flexibly manage and extract the URL addresses of these links is a focus of many operators.

2025-11-06

How to set the `rel="nofollow"` attribute in AnQiCMS友情 links to optimize SEO?

As an experienced website operations expert, I know that every detail can affect the performance of a website in the increasingly complex search engine optimization (SEO) environment.Friendship link, this seemingly simple function plays a role in SEO strategy that requires exquisite balance.Today, let's delve into how AnQiCMS helps us intelligently manage friend links and reasonably set the `rel="nofollow"` attribute to optimize SEO.

2025-11-06

How can AnQiCMS quickly generate placeholder random text in templates?

During the process of website design and development, we often encounter a common but annoying link: the content is not ready, but the page layout and functions need to be tested and improved as soon as possible.If there is no actual content to fill, the visual effects and user experience tests of the page may be greatly reduced.Anqi CMS knows the pain points of content operators and developers at this stage, so it has built-in a very convenient and efficient auxiliary tag——`lorem`, which is specifically used to quickly generate placeholder random text in templates.This `lorem` tag's design inspiration comes from the classic 'Lorem'

2025-11-06