How to call and display the friend link list in AnQiCMS templates?

Calendar 👁️ 64

How to effectively call and display the friend link list in the template when building and managing a website using AnQiCMS is a common and practical need.Friendship links can not only help improve the SEO performance of the website, but also provide users with more valuable external resources.The powerful template engine of AnQiCMS combined with its backend features makes this operation very direct.

Manage friend links: Start from the backend

Before displaying the link on the website front-end, we first need to set it up in the AnQiCMS backend.AnQiCMS provides a user-friendly friend link management feature, allowing you to easily add, edit, and manage your link list.

Log in to the AnQiCMS backend, find "Function Management" in the left navigation bar, and then click on "Friend Link Management".Here, you can see the existing list of friendship links and add new links.

When you add a new link to the friendship, you usually need to fill in the following information:

  • Link NameThis is the name displayed on the website front-end for the friendship link, it should be concise and clear, expressing the content of the link clearly.
  • Link AddressThis is the complete URL pointed to by the friendship link, be sure to ensure its accuracy.
  • NoteYou can fill in some internal descriptions for convenience in management, which are usually not displayed on the front end.
  • Nofollow attributeThis is a very important option. Checking 'nofollow' tells the search engine not to follow the link and not to pass on your website's weight.This is very useful to avoid the impact of unrelated links on the SEO of your website, or when you do not fully trust the content to which the link points.

After completing these settings, save the link, and it will be successfully added to your friend link library.

Call the friend link in the AnQiCMS template

After configuring the friend links on the background, the next step is to display them in the template on the website front end.The AnQiCMS template system adopts syntax similar to the Django template engine and provides special tags for convenient data retrieval.

To display the friend link list, we need to uselinkListthe tag. This tag is specifically designed to retrieve the friend link data configured on the backend.

Its basic usage is:

{% linkList friendLinks %}
    {# 在这里放置循环代码来显示友情链接 #}
{% endlinkList %}

Here, friendLinksThis is a variable name you define, used to receive the data list of friendship links within the tag. ThislinkListThe tag will return an array (or slice) object containing all the friendship link information, with each element representing a friendship link.

We can usefora loop to iterate over thisfriendLinksVariable, and display the detailed information of each link in turn. At the same time, in order to ensure that the HTML structure is only rendered when there are friendship links, we can useifConditional judgment.

Let's look at a specific example of how to organize code in a template to display友情链接

{% linkList friendLinks %}
    {% if friendLinks %}
    <div class="footer-links">
        <h4>友情链接</h4>
        <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 class="link-remark">{{item.Remark}}</span>{% endif %}
            </li>
            {% endfor %}
        </ul>
    </div>
    {% endif %}
{% endlinkList %}

Let's parse this code:

  • {% linkList friendLinks %}and{% endlinkList %}This is the start and end of calling the friendship link tag. It tells AnQiCMS to obtain friendship link data and assign it tofriendLinksVariable.
  • {% if friendLinks %}This is a very practical judgment, it checksfriendLinksThe list is empty. The internal HTML structure will only be rendered when the backend actually adds friendship links, to avoid displaying empty titles or lists when there are no links.
  • <h4>友情链接</h4>and<ul>...</ul>This is the HTML structure we define for the friendship link list, you can adjust it according to the style requirements of your website.
  • {% for item in friendLinks %}ThisforThe loop will iterate overfriendLinksEach link in the list. In each loop, the data of the current link will be assigned toitemVariable.
  • <li>...</li>: List item, used to carry the information of a single link.
  • {{item.Link}}: Display the current friend link URL address.
  • {% if item.Nofollow == 1 %} rel="nofollow"{% endif %}: This is a conditional judgment, if the background is set to 'nofollow' for the link, it will be automatically added here.rel="nofollow"Property. This is an important detail for SEO optimization.
  • target="_blank"This attribute is usually added to friend links to open the link in a new tab, improving user experience and preventing visitors from leaving your website.
  • {{item.Title}}This displays the name of the current friend link.
  • {% if item.Remark %}<span class="link-remark">{{item.Remark}}</span>{% endif %}If the backend has filled in a note for this link, it will be displayed here.

By using such a code structure, you can flexibly call and display the friend link list in the AnQiCMS template.Generally, friend links are placed at the footer of a website or on an independent "friend links" page.

Tips and **Practice

  1. Template File Location Usually, the code snippet for a friend link can be placed in partial/footer.htmlsuch a public file and then accessed by {% include "partial/footer.html" %}The way to reference in other templates, maintain code modularity.
  2. Style beautificationThe above HTML code is just a basic structure, you can customize the CSS style to beautify the display of the friend links so that it matches the overall style of your website.
  3. Multi-site callIf you have used the AnQiCMS multi-site management function and want to call the friendship link of a specific site, you canlinkListthe tag withsiteIdparameters, for example{% linkList friendLinks with siteId="2" %}To specify the friendship links of the site with ID 2. However, for most single-site users, this parameter does not need to be specified.

By following these steps and techniques, you will be able to skillfully manage and display friendship links in the AnQiCMS website template, adding a practical value to your website.


Frequently Asked Questions (FAQ)

1. Ask: What is the use of the friend link's attribute?rel="nofollow"What is the use of the attribute?Answer:rel="nofollow"The attribute tells the search engine not to pass the "weight" or "trustworthiness" of your website to the page linked by this link.This is typically used when you do not want to endorse external links, or when links are advertisements, user-generated content, etc., which helps prevent irrelevant links from affecting the SEO performance of your website and avoiding potential penalty risks.

2. Ask: Why doesn't the friend link I added in the background show up on the front page? What could be the reason?Answer: This could be due to several reasons. First, please check if your template file is using{% linkList friendLinks %}tags correctly, and the internalforIs the loop structure complete? Secondly, confirm whether you have cleared the AnQiCMS system cache (usually there is an 'update cache' option in the background), as template changes and data updates may require cache refresh to take effect.Finally, check if the friendship link you added is set to display status (if there is this option in the backend).

3. Ask: Can I display different friend link lists for different pages or categories on the website?Answer: AnQiCMS'linkListThe tag is mainly used to obtain the global friend link list, it does not provide filtering parameters by category ID or other page attributes directly. If you need to implement this requirement, you can consider classifying the links in the background "Friend Link Management" and filtering them in the template throughifstatements to combineitem.RemarkField or custom logic to manually filter and display. Or, if you are very familiar with template development, you can also consider creating multiple "friend link lists" through content models or single-page functions, and then calling different content based on page ID or category ID.

Related articles

How to insert preset content from the paragraph material library in the article content editor?

In AnQi CMS, efficiently managing and publishing content is the key to improving operational efficiency.For scenarios where frequent use of specific statements, module introductions, or standard declarations is required, manual repetition not only takes time but may also introduce inconsistencies.AnQi CMS understands the value and challenges of content creation, and therefore cleverly integrated the "Paragraph Material Library" feature into the article content editor, aiming to help you easily solve this pain point.Today, let's delve into how to easily insert predefined content from the paragraph material library in the article content editor, to increase your content production efficiency

2025-11-08

How to display all articles under a specific Tag in AnQiCMS?

In AnQiCMS, displaying the list of all articles under a specific tag (Tag) is a common and practical content operation requirement.Through AnQiCMS's flexible template system, you can easily implement this feature, providing users with more accurate content navigation.Let's first understand the tag mechanism in AnQiCMS.Tags are important tools for content organization, allowing you to add keywords to articles, products, and other content to cross-reference related items, even if they belong to different categories.This association method helps users discover more interesting content

2025-11-08

How to integrate the AnQiCMS built-in captcha feature into the comment form to prevent spam?

As website operators, we often encounter a headache-inducing problem: spam.Whether it is a message board or a comment section, unwanted advertisements, malicious links, and meaningless content not only harm the image of the website and increase the management burden, but may also affect the SEO performance of the website.It's good that AnQi CMS considered these security needs from the outset, built-in captcha functionality, and helped us easily deal with these challenges.Today, let's talk about how to integrate this powerful captcha feature into the comment or review form of your Anqi CMS website to keep your site fresh and secure

2025-11-08

How does AnQiCMS implement the dynamic display of breadcrumb navigation through template tags?

In web design, breadcrumb navigation is a seemingly minor but actually crucial feature.It clearly shows the user's current position in the website in a concise path form, not only effectively improves user experience and helps visitors quickly understand the website structure and easily backtrack, but also greatly benefits search engine optimization (SEO), as it can provide clear website hierarchy information for search engine crawlers and enhance the internal link structure of the website.

2025-11-08

How to dynamically display the publication time of an article and format it on the article detail page?

Managing content in AnQi CMS, the publication time is undoubtedly an indispensable important metadata for every article.It not only allows readers to understand the timeliness of the content, but also has a positive impact on the website's SEO.The AnQi CMS provides us with a very convenient and flexible way to dynamically display and format these publishing times on the article detail page. <h3>Get the publication time of the article On the Anqi CMS article detail page, the system will automatically provide us with all the information of the current article as context variables.Among them, the publication time of the article is stored in

2025-11-08

How does AnQiCMS sort articles by view count (Views) and display the most popular articles?

In website operation, how to efficiently display the most popular articles to visitors is a key link to improve user engagement and optimize content strategy.When visitors can easily find the hot content they are interested in, it not only extends their stay on the website but also effectively promotes the spread of content.AnQiCMS provides a flexible and powerful template tag system that allows website managers to easily sort articles by views and display the most popular content without complex technical operations.

2025-11-08

How to implement nested display of multi-level navigation menus in AnQiCMS templates?

Build a clear and feature-rich website in AnQiCMS requires flexible and diverse navigation menus.Multilevel navigation can not only help visitors quickly locate the content they need, but also optimize the website structure and be friendly to search engines.The powerful template engine and background management features of AnQiCMS make it intuitive and efficient to implement complex nested navigation.

2025-11-08

How to set and display the website logo image for AnQiCMS?

On a website built with AnQiCMS, the logo image is a core element of brand recognition, which can not only enhance the professionalism of the website, but also deepen visitors' impression of the brand.AnQiCMS provides a simple and intuitive way to set and display your website logo. ### Set Website Logo: Let the brand identity入驻 AnQiCMS Firstly, to make your website have a unique identifier, the first step is to upload the Logo image to the AnQiCMS backend.This process is very direct: 1.

2025-11-08