How to add image icons instead of text for the links of home, last page, previous page, and next page in pagination tags?

Calendar 👁️ 94

AnQi CMS page navigation gets a new look: goodbye text, embrace personalized image icons

As a senior website operator, we are fully aware of the importance of every detail of user experience.A user-friendly and aesthetically pleasing navigation system can greatly enhance the browsing comfort of users on the website.In AnQiCMS, pagination tags are the core components of the content list page, and they are presented by default in text forms such as 'Home', 'Last Page', 'Previous Page', 'Next Page', and so on.However, in order to pursue more personalized and visually appealing designs, many operators hope to replace these texts with exquisite picture icons.

AnQiCMS is renowned for its efficient Go language architecture and flexible template system, which provides a solid foundation for us to achieve this personalized customization.Today, let's delve into how to cleverly replace the images for the key links such as 'Home', 'Last Page', 'Previous Page', 'Next Page' in the pagination tags of AnQiCMS, making your website shine with unique charm in the details.

Flexible template system is the foundation of customization

The template design of AnQiCMS has borrowed the syntax of Django template engine, allowing developers and operators to deeply customize every display element of the website. All template files are written in.htmlsuffixes stored in/templateIn the catalog, while the styles, JavaScript scripts, and static resources such as images required by the website are all placed in/public/static/Under the directory. It is this clear structure that allows us to modify and expand the page functions with ease.

To replace the pagination icons, we first need to locate the template file that carries the pagination logic. Usually, this will be the content list page (such asarchive/list.html), tag list page (tag/list.htmlOr search result page (search/index.htmlOr a page among theseincludeA common pagination snippet comes in.

Deep understanding of pagination tags (pagination) The mysteries of

AnQiCMS provides a namedpaginationThe powerful tag, used to handle all pagination logic. When you call it in the template like this:

{% pagination pages with show="5" %}
    {# 首页 #}
    <a class="{% if pages.FirstPage.IsCurrent %}active{% endif %}" href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a>
    {# 上一页 #}
    {% if pages.PrevPage %}
    <a href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a>
    {% endif %}
    {# 中间多页 #}
    {% for item in pages.Pages %}
    <a class="{% if item.IsCurrent %}active{% endif %}" href="{{item.Link}}">{{item.Name}}</a>
    {% endfor %}
    {# 下一页 #}
    {% if pages.NextPage %}
    <a href="{{pages.NextPage.Link}}">{{pages.NextPage.Name}}</a>
    {% endif %}
    {# 尾页 #}
    <a class="{% if pages.LastPage.IsCurrent %}active{% endif %}" href="{{pages.LastPage.Link}}">{{pages.LastPage.Name}}</a>
{% endpagination %}

You will noticepagesThe object providesFirstPage/PrevPage/NextPageandLastPageand child objects, each child object containsName(Link text),Link(link address) andIsCurrent(Is it the current page) and other properties. Our goal is to replace the text corresponding to these properties in the sub-objects with the carefully prepared image icons.{"key":2Name属性所对应的文本,替换成我们精心准备的图片图标。

Prepare your pagination icon

Before starting to modify the template, we first need to prepare the required image icons.It is recommended that you prepare an icon for “Home”, “End”, “Previous Page”, and “Next Page” each.In order to maintain good visual effects and loading speed, here are some suggestions:

  1. Choose icon format:
    • SVG (Scalable Vector Graphics):If your icon is a vector graphic, it is strongly recommended to use SVG format. They can be displayed clearly at any size and are usually very small in file size.
    • PNG (Portable Network Graphics):If it is a bitmap icon, PNG is the choice with a transparent background. Please ensure the image size is moderate and compress it for optimization.
  2. Location:Upload the icon file to a subfolder under the static resource directory of your AnQiCMS template, for example/public/static/{您的模板名称}/images/pagination/. Assuming your template name isdefault, the path may be/public/static/default/images/pagination/.
  3. Naming conventions:Give a meaningful and easily recognizable name to the icon, for example:icon-home.svg/icon-prev.svg/icon-next.svg/icon-last.svg.

Modify the template: change text to image icon

Now, let's go back to the template file, replace the text in the pagination links with image icons. The core idea is that we no longer output directly{{pages.FirstPage.Name}}such text, but with a<img>Label to carry the icon.

Before yourpaginationInside the label, find the corresponding links for 'Home', 'End', 'Previous Page', 'Next Page' and modify them:

<div class="pagination">
    {% pagination pages with show="5" %}
    <ul>
        {# 首页链接 #}
        <li class="page-item {% if pages.FirstPage.IsCurrent %}active{% endif %}">
            <a href="{{pages.FirstPage.Link}}" title="首页">
                {%- set homeIconPath = system("TemplateUrl") ~ "/images/pagination/icon-home.svg" %}
                <img src="{{ homeIconPath }}" alt="首页" class="pagination-icon pagination-home-icon" />
            </a>
        </li>

        {# 上一页链接 #}
        {% if pages.PrevPage %}
        <li class="page-item">
            <a href="{{pages.PrevPage.Link}}" title="上一页">
                {%- set prevIconPath = system("TemplateUrl") ~ "/images/pagination/icon-prev.svg" %}
                <img src="{{ prevIconPath }}" alt="上一页" class="pagination-icon pagination-prev-icon" />
            </a>
        </li>
        {% endif %}

        {# 中间多页,保持文字不变 #}
        {% for item in pages.Pages %}
        <li class="page-item {% if item.IsCurrent %}active{% endif %}">
            <a href="{{item.Link}}">{{item.Name}}</a>
        </li>
        {% endfor %}

        {# 下一页链接 #}
        {% if pages.NextPage %}
        <li class="page-item">
            <a href="{{pages.NextPage.Link}}" title="下一页">
                {%- set nextIconPath = system("TemplateUrl") ~ "/images/pagination/icon-next.svg" %}
                <img src="{{ nextIconPath }}" alt="下一页" class="pagination-icon pagination-next-icon" />
            </a>
        </li>
        {% endif %}

        {# 末页链接 #}
        <li class="page-item {% if pages.LastPage.IsCurrent %}active{% endif %}">
            <a href="{{pages.LastPage.Link}}" title="末页">
                {%- set lastIconPath = system("TemplateUrl") ~ "/images/pagination/icon-last.svg" %}
                <img src="{{ lastIconPath }}" alt="末页" class="pagination-icon pagination-last-icon" />
            </a>
        </li>
    </ul>
    {% endpagination %}
</div>

Code analysis:

  1. {%- set homeIconPath = system("TemplateUrl") ~ "/images/pagination/icon-home.svg" %}:
    • We usesetTag defines a variable to store the image path.
    • system("TemplateUrl")It is a system tag provided by AnQiCMS that dynamically retrieves the root directory address of the static files of the current website template.This ensures that even if the website deployment environment changes, the image path can still be correctly parsed.
    • ~The symbol is used to concatenate strings. We concatenate the template URL with the image/images/pagination/path relative to it.
    • {%-and%}of-Symbols are used to remove logical tags (setThe tag itself) may cause extra blank lines during rendering, maintaining the neatness of the HTML output.
  2. <img src="{{ homeIconPath }}" alt="首页" class="pagination-icon pagination-home-icon" />:
    • Here we use<img>tags to display images.
    • srcThe value is the dynamically constructed image path mentioned above.
    • altThe attribute is crucial as it provides the textual description of the image.

Related articles

Is the HTML output structure of AnQiCMS's pagination tag fixed? Can the content of the page number's `<a/>` tag be fully customized?

As an experienced website operations expert, I fully understand the core status of the content management system (CMS) in website construction and daily operations.Especially for basic functions like pagination, flexibility is often directly related to user experience, search engine optimization (SEO), and the aesthetic beauty of front-end design.Many developers and operators are concerned about how much freedom a system like AnQiCMS, which pursues efficiency and customization, provides in the HTML output structure of pagination tags?

2025-11-07

How to use the total page number `TotalPages` returned by the `pagination` tag to implement more complex page jump logic?

AnQiCMS (AnQiCMS) leverages its efficient architecture based on the Go language and flexible template system to provide powerful customization capabilities for content operators.In the presentation of website content, pagination is an extremely common requirement, and our `pagination` tag is born for this purpose.It can not only help you easily build standard pagination navigation, but also provides the valuable property `TotalPages`, allowing you to break free from the shackles of traditional pagination and achieve more intelligent and complex page jump logic.

2025-11-07

Will the `pagination` tag automatically generate the `rel="nofollow"` attribute to some pagination links?

As an experienced website operations expert, I fully understand the importance of each tag and attribute for website search engine optimization (SEO).When it comes to the presentation and indexing of website content, the handling of pagination links is particularly worthy of attention.Today, let's delve into the `pagination` tag in AnqiCMS and whether it automatically adds the `rel="nofollow"` attribute to pagination links.

2025-11-07

How to ensure SEO-friendliness of pagination links in AnQiCMS, avoiding duplicate content or waste of crawling budget?

## Ensure SEO-friendliness of pagination links in AnQiCMS: Avoid duplicate content and crawling budget waste As an experienced website operations expert, I know full well that pagination links are a double-edged sword when it comes to the impact on website SEO.On one hand, they can effectively organize a large amount of content and enhance the user's browsing experience; on the other hand, if not handled properly, they may also lead to waste of search engine crawling budget, excessive duplicate content, and even affect the overall ranking of the website.

2025-11-07

When there are multiple filter conditions, can the `pagination` tag correctly pass all parameters to the next page link?

## The Wisdom of Anqi CMS Pagination Tags: Deep Analysis of Parameter Auto-Transmission under Multi-Condition Filtering In modern website content management, users often need to filter content through multiple conditions to quickly locate the desired information.For example, on an e-commerce website, users may filter products at the same time such as 'T-shirt', 'red', and 'M size';On an article publishing platform, users may filter articles that are 'technical', 'Go language', and 'published in 2023'.After these filtering conditions take effect, users often need to browse more results through the pagination feature. At this time

2025-11-07

How does AnQiCMS pagination tag handle invalid page number requests (such as page numbers out of range)?

As an experienced website operations expert, I am well aware that the core value of a content management system (CMS) lies not only in content publishing, but also in its careful consideration of user experience and search engine optimization (SEO).AnQiCMS is an enterprise-level content management system developed based on the Go language, with its efficient, secure, and SEO-friendly design philosophy, it always shows its unique and comprehensive consideration when dealing with some seemingly trivial but actually crucial functions.

2025-11-07

How to add a unique `data-id` attribute to each page number button in AnQiCMS pagination?

As an old soldier in the field of website operations for many years, I know that every detail can affect the performance of the website, user experience, and even the depth of data analysis.AnQiCMS is a modern content management system developed based on the Go language, providing strong support for our operational work with its high efficiency, flexibility, and ease of expansion.It has a unique Django template engine syntax that allows even relatively complex customization requirements to be implemented elegantly through concise code.Today, let's discuss a very practical little trick in daily operation and data analysis

2025-11-07

`archiveList type="page"` combined with `pagination`, how will pagination adapt when the `limit` value changes?

As an experienced website operations expert, I know that it is crucial to be able to display content flexibly and efficiently in a content management system.AnQiCMS (AnQiCMS) offers great convenience for content operation with its excellent flexibility and powerful template tag system.

2025-11-07