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

Calendar 👁️ 75

As an experienced website operations expert, I know that how to flexibly use template tags to display content in such an efficient content management system as 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.


Unlock AnQi CMS友情链接: Easily obtain the text name (Title) of each link

In today's internet environment, friendship links (also known as external links) are still an indispensable part of the website content ecosystem and search engine optimization (SEO) strategy.They are not only bridges for transmitting trust between websites but also ways for users to find more related resources.For website operators using AnQiCMS to manage the operation, flexibly controlling the display of friendship links, especially the cyclic output of each link's text name, is a very practical skill.AnQiCMS powerful template tag system makes this task extremely simple and intuitive.

Core tool:linkListThe charm of tags

We need to bring out our core tool to loop output the friend links in the AnQiCMS template.linkListLabel. This label is specifically used to obtain the list of friend links configured on the background.Its usage is very concise and clear, allowing you to assign the collection of obtained friendship links to a variable, and then process them one by one through a loop.

Generally, you would start your friend link display area in the template:

{% linkList friendLinks %}
    {# 友情链接将在这里循环输出 #}
{% endlinkList %}

Here, friendLinksThat is the variable name we specify for the collection of friend links. Once this tag is parsed,friendLinksVariables carry all the data of the link friendship, waiting for us to further "review."

Reveal the identity of the link: Get the text name (Title)

When you use{% for item in friendLinks %}Traverse such a loop statementfriendLinksWhen a set,itemThe variable represents an independent friendship link object in each iteration. ThisitemThe object contains all the details of the link, including its text name, link address, notes, and whether it has been setnofollowattributes, etc.

To get the text name of each link, which is itsTitleAttribute, you just need to access it easilyitemthe object'sTitleField, just like this:{{ item.Title }}.

Let's see how it works with a simple example:

{% linkList friendLinks %}
    <div class="friendship-links-section">
        <h4>我们的合作伙伴</h4>
        <ul>
            {% for item in friendLinks %}
                <li>链接文字名称: {{ item.Title }}</li>
            {% endfor %}
        </ul>
    </div>
{% endlinkList %}

This code will iterate through all the links and output the text name of each link.

Beyond the text: Get more link attributes

Except for the text nameTitle,itemThe object also provides several very useful properties, allowing you to build a friendship link display with more features according to your needs:

  • item.Link: The actual URL address of the friendship link.
  • item.Remark: Link remark information, usually as<a>label'stitleAttribute, providing a tooltip when the mouse hovers over
  • item.Nofollow: A boolean value (or equivalent number 1/0), indicating whether the link has been setrel="nofollow"Property. This is very important for SEO, as it can control whether the search engine tracks the link.

Combine these properties, and we can create a more functional and SEO-friendly friend link list:

{% linkList friendLinks %}
    <div class="friendship-links-section">
        <h4>我们的合作伙伴</h4>
        <ul class="footer-links-list">
            {% for item in friendLinks %}
                <li>
                    <a href="{{ item.Link }}"
                       {% if item.Nofollow == 1 %} rel="nofollow"{% endif %}
                       title="{{ item.Remark|default:item.Title }}" {# 如果没有备注,则使用Title作为提示 #}
                       target="_blank">
                        {{ item.Title }}
                    </a>
                </li>
            {% endfor %}
        </ul>
    </div>
{% endlinkList %}

In this example, we not only obtain the text name of the link{{ item.Title }}still according toitem.NofollowThe value dynamically addedrel="nofollow"attributes, and make use ofitem.Remarkto provide a better user experience for links.target="_blank"then make sure that the link opens in a new window to avoid users leaving the current website.

Gracefully handle the case when there are no friendship links

In some cases, your website may not have added any friendship links yet. To avoid blank pages or errors, you can useforin the loop{% empty %}Provide a fallback content block:

{% linkList friendLinks %}
    <div class="friendship-links-section">
        <h4>我们的合作伙伴</h4>
        <ul class="footer-links-list">
            {% for item in friendLinks %}
                <li>
                    <a href="{{ item.Link }}"
                       {% if item.Nofollow == 1 %} rel="nofollow"{% endif %}
                       title="{{ item.Remark|default:item.Title }}"
                       target="_blank">
                        {{ item.Title }}
                    </a>
                </li>
            {% empty %}
                <li>当前暂无友情链接,敬请期待!</li>
            {% endfor %}
        </ul>
    </div>
{% endlinkList %}

Even if no friend links are configured on the backend, the front-end page can still display a prompt message to enhance the user experience.

Summary

The template tag design of AnQiCMS makes tasks like obtaining the text name of a friend link very direct and efficient. ThroughlinkListtags, with the help offorloop anditem.TitleYou can easily access properties and dynamically display and manage friend links at any location on the website.This flexibility not only simplifies front-end development, but also provides strong support for the daily operation of the website and SEO strategy.Master these basic operations and you will be able to better utilize the various functions of AnQiCMS, creating a high-quality website with complete features and user-friendly interface.


Frequently Asked Questions (FAQ)

Q1: I added a friend link in the background, but it didn't show up on the front page. What's the matter? A1:This question usually has several reasons. First, make sure you have used the template correctly.{% linkList friendLinks %}and{% for item in friendLinks %}Such a label structure to traverse and display links. Next, check whether you have correctly added and saved the link in the background "Function Management" -> "Friend Links".Finally, if your website has caching enabled, please try clearing the AnQiCMS system cache to ensure that the latest data is loaded.

Q2: Can I control the display order of friendship links? For example, by publication time or custom sorting? A2:AnQiCMS'linkListLabels are usually sorted according to the default sorting of the friend link in the background management interface (such as ascending order by ID or the priority set by the background). CurrentlylinkListThe label itself does not provide directly.orderThe parameters are used to define the sorting logic of the front-end output. If you need a specific sorting, you may need to adjust the order of adding friend links in the background or use some front-end JavaScript for a second sorting after the page is loaded, but this will increase the complexity of front-end rendering.

Q3: Why do I want to add some friendship links without passing weight?rel="nofollow"How to operate in AnQiCMS? A3: rel="nofollow"The attribute tells the search engine not to follow the link and not to pass the "weight" or "trustworthiness" to the target website of the link.This is usually used for sponsor links, ad links, or external links whose content quality you are unsure of, to avoid affecting the SEO performance of your own website.When managing friend links in the AnQiCMS background, you can set each link individually whether it is enabled or notnofollow. In the template, as shown in the article example, you can{% if item.Nofollow == 1 %} rel="nofollow"{% endif %}This condition judgment is used to dynamically add this property.

Related articles

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

As an experienced website operations expert, I fully understand the crucial 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 deeply into a commonly used and crucial tag in the AnQiCMS template: `{% linkList friendLinks %}`, especially the data structure represented by the `friendLinks` variable, and how to make full use of it to optimize your website.### Decrypt

2025-11-06

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 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

What are the main scenarios where the `lorem` tag is used in AnQiCMS template development?

In AnQiCMS template development, the practical application scenario analysis of the `lorem` tagIn this process full of creativity, a seemingly simple but extremely practical tool - the `lorem` tag, often becomes our powerful assistant for rapid iteration and efficient development.

2025-11-06