As a senior CMS website operation personnel of an information security company, I fully understand that in website operation, friendly links are not only an embodiment of external resource cooperation, but also an important part of SEO optimization and user experience construction.The AnQiCMS has always been dedicated to providing simple and efficient solutions in content management and template integration, and the display of the friendly link list is no exception.

Now, I will introduce to you in detail how to elegantly display the website's link list in the AnQiCMS template.

In modern website operation, friendship links (also commonly referred to as "partners" or "recommended sites") play a significant role in connecting websites with external resources, enhancing search engine visibility, and enriching user navigation.An area of a well-designed, easy-to-manage and display friendship link, which can effectively increase the authority of the website, improve the structure of external links, and provide users with more valuable information.AnQi CMS is an efficient content management system that fully considers this requirement, providing built-in functions and template tags to allow website operators to easily implement the display of友情链接 links.

Understanding AnQiCMS's friend link management mechanism

The management of friend links is integrated into the "Function Management" module of the Anqi CMS backend. Here, you can add, edit, and delete friend links, including setting the link name, URL address, remarks, and whether to addnofollowProperties. The system built-in.linkListTemplate tags are the core tools used by front-end templates to call back-end data.This label is designed to be intuitive and easy to use, conforming to the syntax style of the Django template engine, even beginners in template development can quickly get started.

Steps to display the friend link list in the template.

To display the friend links list in the AnQiCMS template, you mainly need to do two things: determine the display location, and use the correct template tags.

Step one: Select the appropriate template file and display location

Friendship links are usually placed at the footer, sidebar, or an independent 'friendship links' page of a website.

If you wish to display friend links at the bottom of all pages, you may need to edit the template directory used for the common partbash.htmlor the footer defined in your theme.partial/footer.htmlThis type of file. These files are usually accessed by other pages through{% include %}.

If the友情链接 friendship link is only displayed on specific pages, such as the home page, then you can editindex/index.htmlfile.

Find the code area you decide to display for the friendship link.

Step two: UselinkListtags to retrieve and iterate through friendship link data

AnQiCMS provideslinkListLabels, used specifically to retrieve friend link data from the background database. The usage of this tag is very concise.

First, you need to use{% linkList 变量名 %}Define a variable that will store the collection of all friendship links. For example, we can name itfriendLinks.

{% linkList friendLinks %}
    {# 在这里处理 friendLinks 变量 #}
{% endlinkList %}

OncefriendLinksVariable is defined; it will be an array object containing all friendship link information. Next, you need to useforTraverse this array in a loop and display the detailed information of each friendship link one by one.

In each loop,item(或其他您自定义的循环变量名)will represent an independent friendship link object, it contains the following available fields:

  • item.Title[The display name of the friendship link].
  • item.Link: The URL address of the friendship link.
  • item.Remark: English link description (optional).
  • item.Nofollow: A boolean value (or 1/0), indicating whether the link should be addedrel="nofollow"properties.

The following is an example of a complete friendship link list display code:

{% linkList friendLinks %}
    {% if friendLinks %} {# 检查是否存在友情链接,避免在没有链接时显示空标题或区域 #}
    <div class="footer-links">
        <h3>友情链接</h3>
        <ul class="friend-links-list">
            {% for item in friendLinks %}
            <li class="friend-link-item">
                <a href="{{ item.Link }}" {% if item.Nofollow == 1 %}rel="nofollow"{% endif %} target="_blank" title="{{ item.Remark }}">
                    {{ item.Title }}
                </a>
            </li>
            {% endfor %}
        </ul>
    </div>
    {% endif %}
{% endlinkList %}

In this code block:

  1. {% linkList friendLinks %}Label is used to retrieve all the友情链接 links from the background configuration and assign them tofriendLinksa variable.
  2. {% if friendLinks %}The statement ensures that the entire friend link area will be rendered only when there are friend links, preventing the page from appearing blank or with meaningless titles.
  3. <h3>友情链接</h3>and<ul>/<li>The HTML tags are used to construct the structure of lists and provide a title. You can adjust these HTML structures and CSS class names according to your website design.
  4. {% for item in friendLinks %}to iteratefriendLinksArray of each friendship link.
  5. <a href="{{ item.Link }}" ...>Created actual links.{{ item.Link }}Will output the URL of the friendship link.
  6. {% if item.Nofollow == 1 %}rel="nofollow"{% endif %}This line is very critical. It dynamically adds links based on the backend settings.rel="nofollow"The attribute. This is particularly important for SEO management, as it can control the transmission of link weight and avoid unnecessary negative impacts.
  7. target="_blank"The attribute makes the link open in a new tab, enhancing the user experience.
  8. title="{{ item.Remark }}"The remark set in the background is used as the link tip information.
  9. {{ item.Title }}Display the name of the friendship link.
  10. {% endfor %}and{% endif %}End separatelyforloop andifcondition judgment.

Stylized friendship link

The code provided above is the basic HTML structure and does not include any CSS styles.To make the友情链接 list display beautifully on your website, you need to style it with CSS.div.footer-links/ul.friend-links-list/li.friend-link-itemThis class name, define the corresponding style in your theme CSS file.

For example, you can set the link color, font size, adjust the spacing between list items, or horizontally align the list items.

Summary

Through the CMS provided by AnQilinkListTemplate tags and concise Django template syntax make it a direct and flexible process to display a list of friend links on the front end of a website.The operation personnel only needs to manage the friend link data in the background, and then integrate the above template code snippet into the corresponding position on the website, and it can be easily realized.This method not only simplifies the development process, but also provides strong support for external link management and SEO optimization of the website.


Common Questions (FAQ)

1. How to manage友情链接 in AnQi CMS backend?

You can log in to the Anqi CMS backend, navigate to the "Function ManagementnofollowProperties, also, links that are no longer needed can be deleted.

2. Why do friendship links need to be set?rel="nofollow"properties?

rel="nofollow"is an HTML attribute that tells search engines not to consider the link target as an endorsement of the site, nor to pass PageRank (page weight). For friendly links, the use ofnofollowCan avoid the negative SEO impact that may be caused by linking to low-quality websites or excessive link exchange, while maintaining the naturalness and control of the website's external links.The CMS provides the option to directly set this attribute in the background, which is convenient for operation personnel to manage according to SEO strategies.

3. Can I display different groups of friend links on different pages?

[Currently] the 安企CMS[AnQi CMS]linkList标签默认会获取后台“友情链接”功能模块下管理的所有友情链接,并没有直接提供基于“组别”或“类型”进行筛选的参数。如果您有此需求,可能需要在后台创建多个单独的页面(例如“合作伙伴A”、“合作伙伴B”),在每个页面中手动插入对应的友情链接列表内容,或者通过定制开发,在linkListOn the basis of tags, add logic to identify different link groups.