Manage and display friendship links in AnQi CMS is an important task in website operation, it not only helps to improve the quality of external links of the website and enhance the search engine optimization performance, but also provides users with more valuable resources.As an experienced website operator familiar with AnQiCMS, I will elaborate in detail on how to obtain and loop output the friend links in AnQiCMS templates.

Understanding the importance of friendship links and the template mechanism of AnQiCMS

Friendship Links are a form of recommendation between websites, usually appearing as text or image links at the bottom or sidebars of the site.High-quality friendship links can help websites pass on authority, increase traffic entry, and enhance user experience.AnQiCMS as an efficient content management system, provides an intuitive backend management interface to add, edit, and delete friend links, and makes the front-end display effortless through its flexible template tag system.

AnQiCMS's template system is based on syntax similar to Django template engine, using{{变量}}to output variable content, as well as{% 标签 %}Process logic control, such as conditional judgment and loops. All template files are named with.htmlsuffix and stored in/templateUnderstand this basic mechanism is the foundation for successfully implementing the circular output of friendship links in the template.

UselinkListTag retrieve friendship link data

AnQiCMS provides a special template tag for obtaining friend link data.linkListThis label can conveniently retrieve all configured friend links from the background database.

When usinglinkListWhen assigning a tag, its data is usually assigned to a variable, for example,friendLinksThis variable will be an array object containing all the friendship link information.linkListThe basic usage method of the tag is as follows:

{% linkList friendLinks %}
    {# 在这里处理友情链接数据 #}
{% endlinkList %}

linkListThe tag also supports an optional parametersiteIdIf you have enabled the multi-site management feature in the AnQiCMS backend and want to get the friend links of a specific site, you can do so by specifyingsiteIdTo complete. But for most single-site cases, this parameter can be omitted, the system will automatically obtain the current site's friend links.

In{% linkList friendLinks %}and{% endlinkList %}You can access between these tagsfriendLinksvariable. SincefriendLinksis an array object, you need to useforto iterate over each friendship link item.

Loop to output the detailed steps of friendship link.

Now, let's build the code step by step to output the friend links in the template:

Firstly, determine where you want to display the友情链接 (Friendship Link) location.This is usually in the footer (footer.html), sidebar (sidebar.html), or a dedicated "friend links" page.Suppose we want to display the friend links in the footer.

Next, in the corresponding template file (for examplepartial/footer.html), insertlinkListLabel, and name the list of links obtainedfriendLinks:

<div class="friendship-links">
    <h3>友情链接</h3>
    <ul>
        {% linkList friendLinks %}
            {# 友情链接列表将在这里生成 #}
        {% endlinkList %}
    </ul>
</div>

To ensure that the entire block is displayed only when there is friendship link data, we can add aif friendLinksThe condition judgment, so as to avoid displaying empty titles and list structures when there is no link, enhancing the robustness of the template:.

<div class="friendship-links">
    {% linkList friendLinks %}
        {% if friendLinks %} {# 检查 friendLinks 数组是否为空 #}
            <h3>友情链接</h3>
            <ul>
                {# 友情链接列表将在这里生成 #}
            </ul>
        {% endif %}
    {% endlinkList %}
</div>

Then, in<ul>to be used inside tagsforto iteratefriendLinksarray. In each loop, a variable nameditemThe variable will represent the current link object. You can accessitemdifferent properties of the object to get the details of the link:

  • item.Title: The display name of the link.
  • item.Link: The target URL address of the link.
  • item.RemarkThe remark information of the link.
  • item.NofollowAn indicator (or 1/0) that specifies whether to addrel="nofollow"properties.

By combining these properties, we can construct the HTML structure for each link:

<div class="friendship-links">
    {% linkList friendLinks %}
        {% if friendLinks %}
            <h3>友情链接</h3>
            <ul>
                {% for item in friendLinks %}
                    <li>
                        <a href="{{ item.Link }}" {% if item.Nofollow == 1 %} rel="nofollow"{% endif %} target="_blank">{{ item.Title }}</a>
                    </li>
                {% endfor %}
            </ul>
        {% endif %}
    {% endlinkList %}
</div>

In this code snippet:

  • href="{{ item.Link }}"Sets the target address of the link.
  • {% if item.Nofollow == 1 %} rel="nofollow"{% endif %}is a conditional judgment, if the back-end has set this link asnofollow, then add the corresponding property on the front-end. This is very important for controlling the page weight flow and meeting search engine standards.
  • target="_blank"English for auto is 'English'. It is usually used for friendship links, ensuring that the link opens in a new tab to avoid users leaving the current website.
  • {{ item.Title }}It shows the text content of the link.

Through the above steps, you can get and flexibly loop output the friendship link in the AnQiCMS template.

Operation consideration and **practice

In displaying friendship links in the template, in addition to technical implementation, some operational and SEO practices need to be considered:**

  1. Link qualityAlways prioritize the exchange of friendship links with websites that are highly relevant to content, have high weight, and are updated actively. Avoid establishing links with bad websites or websites with unhealthy content.
  2. nofollowApplication of properties:For some links whose content quality you are not sure of, but still need to display, or purely advertising links, userel="nofollow"You can tell the search engine not to track this link, thus avoiding a negative impact on the SEO of your website.AnQiCMS backend provides this feature, the template also includes the corresponding judgment.
  3. Layout and user experience:Friendship links are usually placed at the bottom of the website or in less prominent positions to avoid interfering with the main content. Make sure the link text is clear and readable, and the color has enough contrast with the background.
  4. Regular maintenance:Friend link needs to be checked regularly.The website may be redesigned, closed, or links may be invalid.Update or delete expired links in a timely manner can help maintain the professionalism of the website and the friendliness to search engines.

MasteredlinkListThe usage of tags, combined with appropriate operation strategies, will enable your AnQiCMS website to better manage and utilize the resource of friend links.


Common Questions and Answers (FAQ)

1. I added a friendship link in the background, why isn't it displayed on the front page?

可能的原因有几个:首先,请检查您是否已将上述代码添加到正确的模板文件中,例如您网站的页脚或侧边栏模板。其次,确认您的模板文件中使用的变量名(例如friendLinks) corresponds to{% linkList %}The names defined in the tag are consistent.Finally, please clear the website cache in the "Update Cache" feature of the AnQiCMS backend. Sometimes, cache can cause new content not to be displayed on the front end in a timely manner.

2. Where is the AnQiCMS backend to manage friend links?

In the AnQiCMS backend management interface, you can find the "Function Management" module through the left navigation menu.Click to enter, and there will usually be a sub-menu item named "Friend Links".nofollowand sorting information.

3. Can I display different groups of friendship links at different locations in AnQiCMS, such as 'Partners' and 'Personal Blogs'?

Based on the current AnQiCMS documentation,linkListThe label itself does not provide a direct 'Group' filter function.It will retrieve all the background-configured friend links.

  • back-end management levelIn the "NotesifConditional judgmentitem.RemarkField to manually filter and output separately to different HTML areas.
  • Custom field/tag:If the system supports it, you can also consider adding custom fields to distinguish groups for friendship links, and control more flexibly through advanced template logic. However, this may require in-depth template development knowledge or AnQiCMS secondary development capabilities.