In website operation, friendship links play an indispensable role.It is not only an effective way for websites to recommend and share traffic among each other, but also an important means to enhance the weight and visibility of a website in search engines.However, how to conveniently manage and display these links on a website is a practical problem faced by many website managers.AnQiCMS is a system focused on enterprise-level content management and SEO optimization, providing an intuitive friend link function and a flexible template calling mechanism, making this process extremely simple.

Friend link management in AnQi CMS

To display the友情链接 on the bottom of your website, you first need to configure these links in the AnQiCMS backend system.

  1. Enter the backend managementLog in to your AnQiCMS backend, you can usually find the 'Function Management' menu in the left navigation bar.
  2. Visit 'Friend Links':Click on the 'Function Management' sub-menu under 'Friend Links', you will enter the management interface for Friend Links.
  3. Add and editOn this interface, you can easily add new friendship links, or edit and delete existing links. When adding or editing, you need to fill in the following key information:
    • Link NameThis is the text that will be displayed on your website, used to describe the friendship link.
    • Link AddressThis is the complete URL address pointed to by the friendship link.
    • Link noteThis is an optional internal note field, convenient for you to manage and identify different links, it will not be displayed on the website front end.
    • NofollowThis is a very important SEO option. Checking this option will inform the search engine not to pass the weight of your website to the website linked by the link.This is very useful when linking to business partners, advertisements, or websites you do not want to provide SEO benefits to.

Configure all the necessary friend links and save your changes.

Call the friend links in the website footer template

AnQiCMS uses the Django template engine syntax, which means you can call the background configuration data in template files through concise tags.To display the friend link list at the bottom of the website, you need to make corresponding modifications to the template file.

  1. Confirm the footer template fileIn the AnQiCMS template root directory (usually/template/您的模板名称/), find the template file responsible for displaying the bottom area of the website. Common public footer file paths may bepartial/footer.htmlor directly integrated inbase.htmlIn Chinese. If you are not sure which file it is, you can check the template directory structure or checkbase.htmlpass through{% include %}The common part introduced by the tag.

  2. InsertlinkListTagIn the bottom template file found, select a suitable position to display the friend links, such as above the copyright information. Then, insert the following template code:

    {% linkList friendLinks %}
        {% if friendLinks %}
            <div class="footer-friend-links-section">
                <h4>友情链接</h4>
                <ul class="friend-links-list">
                    {% 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 decode the meaning of this code:

    • {% linkList friendLinks %}This is a built-in template tag that is used to retrieve all the configured friend link data from the AnQiCMS backend and assign these data as a list to a variable namedfriendLinks.
    • {% if friendLinks %}This conditional judgment statement is very practical. It will checkfriendLinksWhether a variable contains any data. If no friend links are set in the background or the number of links is zero, the entire friend link area (including the 'Friend Links' title and list) will not be displayed on the website, avoiding blank pages or unnecessary elements.
    • <div class="footer-friend-links-section"> ... </div>and<h4>友情链接</h4>This part is an HTML structure used to wrap the list of friend links and provide a title. You can adjust it according to your website design and style requirements.
    • {% for item in friendLinks %}This is a loop tag, it will iterate overfriendLinkseach friendship link item in the list. In each iteration, all information of the current link will be temporarily assigned toitemVariable.
    • <li> ... </li>Each friendship link is wrapped in a list item.<li>.
    • <a href="{{item.Link}}" {% if item.Nofollow == 1 %} rel="nofollow"{% endif %} target="_blank">{{item.Title}}</a>This is the core code for displaying a single friendship link.
      • href="{{item.Link}}"Dynamically outputs the URL address of the friendship link.
      • {{item.Title}}: Dynamically outputs the name of the friendship link.
      • {% if item.Nofollow == 1 %} rel="nofollow"{% endif %}: This is an important conditional judgment. If the "Nofollow" option is checked for this link (indicatingitem.Nofollowhas a value of 1), then<a>Labels will be automatically addedrel="nofollow"Property.
      • target="_blank"It is usually good practice to open friend links in a new window or tab so that users visiting friend links will not leave your current website.

Save and view effects

After modifying the template file, please save the file. If your AnQiCMS is deployed in a production environment and page caching is enabled, you may need to clear the website cache (which can be found in the "Update Cache" feature of the AnQiCMS backend, or through server operations) to make the changes take effect. Refresh your website homepage, and you should see the new list of友情链接(friendship links) added at the bottom.

Summary

By using the intuitive backend management interface and powerful template tag features of AnQiCMS, you can efficiently and flexibly display友情链接 at the bottom of your website.This integrated solution not only simplifies the management process, but also helps you better optimize the external link strategy of your website through detailed SEO options, thereby improving the overall website operation effect.


Frequently Asked Questions (FAQ)

1. Q: Can I control the number of displayed friend links, such as showing only 5 or 10 of them?

Answer:linkListThe tag itself does not provide directlimitParameters can limit the number of items retrieved. If you want to control the number of items displayed, you can use loop variables in the template's{% for item in friendLinks %}loop, using loop variables (for exampleforloop.CounterPerform a conditional judgment. For example, if you want to display only the first 5 links, you can modify it like this:{% for item in friendLinks %} {% if forloop.Counter <= 5 %} <li>...</li> {% endif %} {% endfor %}Or directly inforAdd in the loopsliceFilter to slice the array:{% for item in friendLinks|slice:":5" %}.

2. Ask: I hope to display my friend links in groups, such as 'Partners' and 'Industry Media', does AnQiCMS support this?

Answer:linkListThe tag retrieves all the友情链接 links from the backend, does not have built-in grouping functions.To implement grouped display, a common method is to use the "link note" field when adding friend links in the background to add group tags to each link (for example: "Partners" or "Industry Media").Then in the template, you can write multiple separatelylinkListtags, and according to the loop insideitem.RemarkThe value is used for conditional judgment to filter and display:{% for item in friendLinks %} {% if item.Remark == "合作伙伴" %} <li>...</li> {% endif %} {% endfor %}You can also usefilterFilter combinationcontainFilter to achieve more flexible filtering effects.

3. Ask: What is the specific function of the 'Nofollow' attribute in the friendship link? When should I check it?

Answer: 'Nofollow' is an HTML<a>A tag attribute that indicates to the search engine not to follow the link and not to assign any "weight"