How to display a list of website friend links in the front-end template?

Calendar 👁️ 67

In website operation, friendship links are not only bridges for communication between websites, but also one of the important strategies to improve website authority, increase external traffic, and optimize search engine rankings.Reasonably configure and display friendship links, which can effectively improve the website's SEO performance and provide users with more valuable external resources.AnQiCMS as an efficient content management system fully considers this requirement and provides a simple and intuitive way to manage and display friend links in the front-end template.

Backend management: Setting and maintenance of friend links

To display the friend link on the front-end page, you first need to manage and configure it in the AnQiCMS backend.The system provides a dedicated module for you to easily complete these operations.

You can navigate to the 'Function Management' module through the backend and then find the 'Friend Link Management'. Here, you can easily add, edit, or delete friend links, and set the name, URL, notes, and whether to add for each link.nofollowProperty information.nofollowThe setting of the property is particularly important, as it helps you control the relationship between the website and external links, avoid unnecessary SEO risks, and ensure link quality.

Front-end display: How to call the friend link through the template tag

Once the friend link is set up in the background, the next step is how to display them in the website's front-end template.AnQiCMS uses a syntax similar to the Django template engine, allowing dynamic data calls with concise template tags.For the list of友情 links, the system provides a special label-linkListThis tag can help us easily get all the configured friend link data.

To display友情链接 on your website template, you can place the following code snippet at the desired location, for example, the footer of the website ( footer.html) or sidebar (sidebar.html):

{% linkList friendLinks %}
{% if friendLinks %}
<div class="friendly-links-section">
    <h3>友情链接</h3>
    <ul class="friendly-links-list">
        {% for item in friendLinks %}
        <li class="link-item">
            <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 go into a detailed explanation of this code:

first, {% linkList friendLinks %}It is the core tag for calling the friendship link. It will retrieve all the configured friendship link data from the AnQiCMS background and store it in a namedfriendLinksthe variable is used later.{% endlinkList %}marks the end of the tag call.

Then,{% if friendLinks %}The statement is a conditional judgment, it checksfriendLinksDoes the variable have actual data. It is a good programming habit to avoid displaying an empty area on the page when there are no friendship links, enhancing the user experience.

If there is a link to friendship, the code will enter adivcontainer, usually you can add some CSS classes (such asfriendly-links-section) for style control. Among them<h3>友情链接</h3>Is a title, you can modify or remove it according to your needs.

The core display logic lies in{% for item in friendLinks %}Loop. This loop will traversefriendLinksEach friendship link in the list, with each iteration, the data of the current link is assigned toitemVariable.

Inside the loop,<li>an element is used to wrap a single friendship link.item.LinkThe URL address is obtained from the link settings you have set in the background,item.Titlewhich is the display name of the link.

Especially note that{% if item.Nofollow == 1 %} rel="nofollow"{% endif %}This code. It will automatically add the 'nofollow' option in the HTML tag based on whether you have checked the 'nofollow' option for this friendship link in the backgroundrel="nofollow"Properties. This is crucial for informing search engines not to follow this link and pass on weight, which helps maintain the SEO health of your website. At the same time,target="_blank"The attribute is a common practice that will make the friendship link open in a new window or new tab, to avoid users leaving your website.

Finally,{% if item.Remark %}<span class="link-remark">({{ item.Remark }})</span>{% endif %}Allow you to display remarks added to the link in the background, which is very useful for some friendship links that require additional explanations.

Flexible application and precautions

This code provides the core data calling logic. As for the style and layout of the friend link, you can beautify and adjust it according to the overall design of the website, such as setting link color, font size, list spacing, etc.

If you are using the multi-site management feature of AnQiCMS and want to call the friendship link of other sites, you canlinkListthe tag withsiteIdparameters, for example{% linkList friendLinks with siteId="2" %}. Here,"2"represent the ID of the target site you want to call.

provided by AnQiCMSlinkListTags and flexible template syntax make displaying friend links very simple and efficient.This not only helps you optimize the SEO performance of your website, but also provides users with a better navigation experience.


Frequently Asked Questions (FAQ)

1. The friend link'snofollowWhat is the role of the property? When should I use it?

nofollow

Related articles

How to extract the article summary and add an ellipsis in AnQiCMS template?

In website operation, how to make the article list page both beautiful and informative is a common concern.Generally, we do not display the full content of the article on the list page, but instead use a short 'abstract' to attract readers to click.To maintain the cleanliness and professionalism of the page, these summaries often need to be automatically truncated when exceeding a certain length and appended with an elegant ellipsis.AnQiCMS is a powerful content management system that provides flexible tools in the template to help us meet this need.Below, we will discuss in detail how to use AnQiCMS

2025-11-07

How to implement safe output of HTML tags in article content to avoid XSS attacks?

In AnQiCMS, we not only pursue efficient and flexible content management, but also regard website security as a core element.In daily content creation and template development, a seemingly simple HTML tag output actually hides potential security risks, the most common of which is cross-site scripting (XSS) attack.Understanding how AnQiCMS processes HTML output and mastering security practices is crucial for building a robust and reliable website.How does AnQiCMS handle HTML content output?In AnQiCMS template rendering mechanism

2025-11-07

How to determine if a variable is empty in AnQiCMS template and display default content?

In website content operation, data integrity and the elegance of display are crucial.We often encounter such situations: some fields of data may be missing for various reasons, such as an article may not have an illustration, a product may not have a detailed description, or a custom field may not be filled in.If the template code does not perform the corresponding null value judgment, it may result in blank pages on the page, affecting the aesthetics, or may even cause template rendering errors, affecting the user experience.AnQiCMS with its efficient architecture based on the Go language and similar to Django

2025-11-07

How to display a custom page template independently on a specific page (such as About Us)?

Hello! When using AnQi CMS to build a website, we often encounter such needs: some specific pages, such as 'About Us', 'Contact Us', or some special topic pages, need to have a completely different layout and design from other pages on the website.Luckyly, AnQi CMS provides a very flexible solution for this, allowing you to easily specify independent custom templates for these pages.AnQi CMS with its efficient features based on the Go language and support for Django template engine syntax, brings great convenience and customizability to content display

2025-11-07

How to display a user comment list on the front end and support review status display?

User comments are an important manifestation of website vitality, they not only enhance the interactivity of content but also provide valuable reference for other visitors.AnQi CMS understands the importance of comment management, providing simple and powerful features that allow you to flexibly display comment lists on the website front end and clearly identify the review status of comments.The core of displaying the comment list on the front-end: `commentList` tag To display user comments on your website's front-end page, you need to use the `commentList` template tag provided by AnQiCMS

2025-11-07

How to dynamically display the website's logo image in the template of AnQiCMS?

The website's logo is the core of the brand image, it not only enhances the professionalism of the website, but also facilitates users in quickly identifying and remembering your brand.For AnQiCMS users, dynamically displaying the logo image in the website template is a basic and important operation.Luckyly, AnQiCMS provides a very convenient way to achieve this, allowing you to easily manage and display the website logo without writing complex code.### Website Logo Management: Backend settings are crucial Display the Logo on your AnQiCMS website

2025-11-07

How to insert Markdown formatted text in website content and render it correctly as HTML?

In AnQiCMS, inserting Markdown formatted text and rendering it correctly to HTML is an important way for content operators to improve efficiency and produce high-quality pages.AnQiCMS has built-in support for Markdown editing and rendering, allowing you to enjoy the simplicity and efficiency of Markdown while ensuring that the final page output is beautiful and structured HTML.### Enable Markdown Editor To start using Markdown in AnQiCMS, you first need to ensure that the editor feature is enabled

2025-11-07

How to correctly display mathematical formulas and flowcharts in the template of AnQiCMS?

Today, with the increasing refinement of content management, websites not only carry text and images but also need to present complex information in a professional and understandable way, such as mathematical formulas and flowcharts.AnQiCMS is dedicated to providing efficient and flexible content management solutions. When we deal with technical articles, academic content, or business process diagrams on the website, how to ensure that these special elements are displayed correctly and beautifully becomes a topic worth discussing.AnQiCMS itself provides good support for Markdown editors, which means we can use concise

2025-11-07