How to display article thumbnails in the Anqi CMS article list?

Calendar 👁️ 67

Practical guide to elegantly displaying thumbnails in the Anqi CMS article list

In website operation, the visual appeal of the article list page is crucial.A carefully selected or automatically generated thumbnail that can quickly capture the visitor's attention, convey the theme of the article, and thereby improve click-through rate and optimize user experience.The AnQi CMS provides flexible and powerful features to help us easily implement displaying article thumbnails in the article list.

This article will delve into how to manage and utilize article thumbnails in Anqi CMS, and provide detailed template code examples to make your article list more attractive.

Understand the 'origin and development' of article thumbnails

In AnQi CMS, there are many ways to generate and manage article thumbnails:

  1. Manual upload:When you publish documents or edit articles under "Content Management" in the background, you can manually upload an image as a thumbnail for the article in the "Document Images" area.This is the most direct and recommended way to ensure that the thumbnail is highly relevant and beautiful.
  2. Automatically extract:If you do not manually upload a thumbnail when publishing an article, but the article content contains images, Anqicms will 'intelligently' extract the first image from the article content as the thumbnail of the article.
  3. Default thumbnail: If the article does not have a thumbnail manually uploaded and does not contain any images in the content, the system will call the default thumbnail preset in the "background settings" -> "content settings".This ensures that the article list maintains a consistent visual presentation even without a specific thumbnail, avoiding blank spaces.

All uploaded images, including thumbnails, will be concentrated under 'Page Resources' under 'Image Resource Management' for easy viewing and management.

The core of displaying thumbnails in the article list - template tagsarchiveList

The article list page is the most common and most important scene for displaying thumbnails. Anqi CMS template system provides powerfularchiveListLabel to flexibly retrieve article list data. InarchiveListwe can easily access the thumbnail information of each article in the loop.

Here are the key steps and code examples for implementing the thumbnail display of article lists:

1. Prepare the template file:通常,文章列表会显示在首页(index/index.html), category list page ({模型table}/list.htmlormobile/{模型table}/list.htmlOr search result page (search/index.html)et al. You need to modify the template file accordingly.

2. UsearchiveListTag to retrieve article data: archiveListThe tag allows you to get a list of articles based on various conditions such as category, model, sorting method, and more. Under the tag'sforthe loop,itemThe variable represents the data of each article, which includes the thumbnail information we need.

The most commonly used thumbnail field isitem.Thumb(Thumbnail of the article cover) anditem.Logo(Article cover main image). Usuallyitem.ThumbIt will be processed by the system into a size more suitable for list display, whileitem.LogoIt could be the original large image uploaded.

Code example:Below is a basicarchiveListLoop, demonstrate how to integrate article thumbnails:

`twig {# Assuming you are in an article list template, such as archive/list.html or index.html #}

{# 使用 archiveList 标签获取文章列表。type="page" 用于分页,limit控制每页数量 #}
{% archiveList archives with type="page" limit="10" %}
    {% for item in archives %}
    <article class="article-item">
        <a href="{{ item.Link }}" class="article-link">
            {# 检查是否存在缩略图。推荐使用 item.Thumb #}
            {% if item.Thumb %}
                <div class="article-thumbnail">
                    <img src="{{ item.Thumb }}" alt="{{ item.Title }}" loading="lazy" /> {# loading="lazy"有助于图片懒加载,优化性能 #}
                </div>
            {% else %}
                {# 如果没有缩略图,可以显示一个默认的占位图片。请替换为您自己的默认图片路径 #}
                <div class="article-thumbnail article-thumbnail-placeholder">
                    <img src="/public/static/images/default-thumbnail.jpg" alt="{{ item.Title }} 暂无图片" loading="lazy" />
                </div>
            {% endif %}

            <div class="article-info">
                <h2 class="article-title">{{ item.Title }}</h2>
                <p class="article-description">{{ item.Description }}</p>
                <div class="article-meta">
                    <span>发布于: {{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                    <span>浏览量: {{ item.Views }}</span>
                </div>
            </div>
        </a>
    </article>
    {% empty %}
    <p>暂无文章内容。</p>
    {% endfor %}
{% endarchiveList %}

{# 如果是分页列表,别忘了添加分页标签 #}
<div class="pagination-container">
    {% pagination pages with show="5" %}
        {# 这里是分页的HTML结构,例如首页、上一页、页码列表、下一页、尾页等 #}
        <ul>
            <li class="page-item {% if pages.FirstPage.IsCurrent %}active{% endif %}">
                <a href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a>
            </li>
            {% if pages.PrevPage %}
            <li class="page-item"><a href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a></li>
            {% endif %}
            {% for pageItem in pages.Pages %}
            <li class="page-item {% if pageItem.IsCurrent %}active{% endif %}">
                <a href="{{pageItem.Link}}">{{pageItem.Name}}</a>
            </li>
            {% endfor %}
            {% if pages.NextPage %}
            <li class="page-item"><a href="{{pages.NextPage.Link}}">{{

Related articles

How to call and display custom parameter fields of articles in the Anqi CMS template?

In AnQi CMS, the custom parameter field of the article is an important manifestation of its core feature of 'flexible content model'.It allows us to define unique additional attributes for different types of content (such as articles, products), greatly enhancing the expressiveness of content and the customization capabilities of the website.Imagine if your website needs to display product details, in addition to the general information such as title, content, and images, you may also need specific parameters such as 'model number', 'color', 'storage capacity', and so on.These are the places where custom parameter fields take effect.

2025-11-08

How to customize the title display format of AnQi CMS article detail page?

The secret to flexibly customizing the CMS article detail page title display formatIt not only affects the identification of users in browser tabs and favorites, but is also one of the key elements of search engine optimization (SEO).A clear, attractive, and well-formatted title that can effectively improve the click-through rate of the article and the professional image of the website.

2025-11-08

How to display the latest published article list on the homepage of AnQiCMS?

In Anqi CMS, the homepage carries the important responsibility of attracting visitors and displaying the latest news.Generally, displaying the latest list of published articles in a prominent position on the homepage is an effective way to enhance user experience and guide content browsing.AnQi CMS with its flexible template system and powerful content management features makes this operation very direct and efficient.

2025-11-08

How to remove specific characters or spaces from the beginning and end of a string in AnQiCMS template?

When using AnQiCMS for website content management, we often encounter situations where we need to refine the output strings in the template.For example, the text obtained from the database may contain unnecessary leading and trailing spaces, or in some specific scenarios, it may be necessary to remove the specific symbols from the beginning or end of the string to ensure the neat display of the page and the uniformity of data format.The powerful template engine of AnQi CMS provides a variety of practical filters that can easily handle these string processing requirements.

2025-11-08

How to display hot articles on the AnQiCMS homepage based on article views?

On AnQiCMS, the homepage is usually the important entry point for visitors to understand the website content and quickly obtain information.Effectively display popular articles, not only to attract users' attention, improve content exposure, but also effectively enhance the user experience of the website and PV (page views).AnQiCMS with its flexible template tags and built-in features makes this operation very simple and intuitive.

2025-11-08

How to implement 'Previous' and 'Next' document navigation on the AnQiCMS article detail page?

In Anqi CMS, implementing the "Previous" and "Next" navigation functions on the article detail page is a key link in improving user experience, guiding users to delve deeper into the website's content, and also helps optimize the internal link structure of the website, which is greatly beneficial for SEO performance.AnQiCMS has a powerful template system and flexible tag features, making this operation intuitive and efficient.### How to implement 'Previous' and 'Next' document navigation in AnQiCMS AnQiCMS has designed a series of convenient template tags specifically for retrieving information about adjacent documents in the article detail page

2025-11-08

How to configure the lazy loading effect of images in the AnQiCMS article content?

In AnQiCMS, optimizing website loading speed is a key step to improving user experience and search engine rankings.When the article content contains a large number of images, these images will significantly increase the page loading time.Image lazy loading (Lazy Loading) is an efficient way to solve this problem, it can prevent images from loading until they enter the user's field of vision, thereby speeding up the initial rendering speed of the page.AnQiCMS as a content management system focusing on performance and SEO provides flexible support for lazy loading images in article content.You can configure the template simply

2025-11-08

How to correctly render Markdown formatted article content in AnQi CMS and display it?

Today, with the increasing efficiency in content creation, Markdown is favored by content creators for its concise syntax and focus on the content itself.AnQi CMS understands this trend and provides powerful features that allow you to easily convert Markdown-formatted article content into exquisite HTML pages and support richer display effects, such as mathematical formulas and flowcharts.

2025-11-08