In website operation, friendship links play an indispensable role. They not only bring valuable external traffic to the website but also help to improve the search engine optimization (SEO) effect, enhance the authority and credibility of the website.For users who use AnQiCMS, managing and displaying friend links is a simple and efficient process.This article will introduce in detail how to configure the友情链接 in AnQiCMS backend, as well as how to elegantly present them in your website front-end template.
Manage friend links in AnQiCMS backend
First, in order to display the link of friendship on your website, you need to configure it in the AnQiCMS backend.AnQiCMS provides an intuitive management interface that allows you to easily add, edit, and delete friend links.
Log in to your AnQiCMS backend and you can find the "Friend Links" option in the "Function Management" section of the left menu.Click to enter, you will see a list page displaying all the currently configured friend links.Here, you can click the 'Add New Link' button.
On the interface for adding or editing friend links, you usually need to fill in the following information:
- Link name:This is usually the text of the friend link that will be displayed on your website.
- Link address:This is the URL pointing to the friendship link.
- whether
nofollow:This is an important SEO option. If checked, it will add to the link.rel="nofollow"Attribute, tell the search engine not to pass the 'weight' to this link, which is very helpful for managing the SEO risk of external links. - Display order:Used to control the order of the links.
After filling in the information, save it. In this way, your friend link data has already been stored in the AnQiCMS database.
Display the friend link in the front-end template
After the background data configuration is completed, the next step is to show these links on the website's front-end template.The powerful template system of AnQiCMS makes this process very intuitive, it uses syntax similar to Django template engine, making content presentation flexible and simple.
We need to use AnQiCMS built-in to retrieve and display the friend link list in the templatelinkListLabel. This label is specifically used to retrieve the friend link data configured on the background.It will return an array (or slice) object containing all the configured friendship links, and we can simply iterate over this array to display the links one by one on the page.
Generally, friend links are placed in the footer area of a website or on a separate "friend links" page. Here is an example code snippet showing how to display friend links in a template:
{% 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>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endlinkList %}
Let's break down this code and see how it works:
{% linkList friendLinks %}: This is the core tag, indicating that AnQiCMS should retrieve all the friend link data and assign it to a variable namedfriendLinks.{% if friendLinks %}: This is a conditional judgment. Good programming practice is to check firstfriendLinksDoes the variable have actual data. If there is a friendship link, the content within the code block will be executed, which can prevent displaying empty titles or lists when there are no links, keeping the page neat.<div class="footer-links">...</div>: This is the HTML structure used to wrap the list of friend links, you can adjust the class name and structure according to your website style.{% for item in friendLinks %}IffriendLinksThere is data, thisforThe loop will iterate over each friendship link. In each iteration, the current friendship link data will be assigned toitemVariable.<li><a href="{{item.Link}}" ...>{{item.Title}}</a></li>: Inside the loop, we useitemVariables to access the properties of each link.{{item.Link}}Displays the current friendship link's URL address.{{item.Title}}It will output the display name of the current friendship link.
{% if item.Nofollow == 1 %} rel="nofollow"{% endif %}: This is an inline conditional judgment. It checks whether the current friendship link is set in the background asnofollowIfitem.NofollowThe value is 1 (indicating it is checked)nofollowThenrel="nofollow"The property will be added to<a>In the tag. This allows you to precisely control the SEO attributes of each link, very practical.target="_blank"This is a common HTML attribute, usually used for friend links, indicating that the link will open in a new tab to keep the user browsing on your website.
If you have enabled the multi-site management feature in AnQiCMS and want to get the friend links of other sites in a specific site template,linkListLabels also support asiteIdthe parameters. For example,{% linkList friendLinks with siteId="2" %}You can retrieve the friend links of the site with ID 2. However, this parameter does not need to be specified in most single-site scenarios.
Summary
Configure the link through the friendly management interface of AnQiCMS backend, and combine it with the concise and powerful front-end templatelinkListLabels, you will find that displaying the website's friendship link list is a pleasant and enjoyable experience.This seamless integration of content management not only saves a lot of development time, but also ensures the flexibility and efficiency of website content management, allowing you to better focus on the operation of website content and the implementation of SEO strategies.
Frequently Asked Questions (FAQ)
Q1: What will be displayed on the front-end template if I do not add any friendship links in the AnQiCMS backend?
A1: If no friendship links are configured in the backend,{% linkList friendLinks %}Tags retrieved from comments.friendLinksThe variable will be an empty array. Since the sample code included{% if friendLinks %}this judgment, so the entire area containing thedivfriendship links (including the 'friendship links' title andulThe list) will not be rendered, no content will be displayed on the page, maintaining cleanliness.
Q2: In the friendship linknofollowWhat is the role of the attribute? When should I use it?
A2:nofollowis HTML<a>one of the labelsrelThe attribute tells the search engine not to pass the "PageRank" (page authority) from your website to the linked website. This is typically used in the following situations:
- Link to a website you do not fully trust.
- Link to a comment section or forum post with user-generated content (to prevent spam links).
- Friendship link or advertising link, when you do not want to be misunderstood as 'selling link weight'.
- If a friendship link website has low quality or does not have much relevance to your topic, use
nofollowCan help you avoid potential SEO risks.
Q3: Can I customize the style and layout of the friend links?
A3: Of course you can. AnQiCMS's template system is very flexible, allowing you to fully control the front-end display of HTML structure and CSS styles. The example code contains the following.div/h4/ul/liandaLabels can be freely modified according to your design requirements. You just need to edit the corresponding template file (usuallyfooter.htmlOr other page templates that include friendship links), then add the corresponding class names or styles according to your website's CSS rules.