In AnQiCMS, flexibly displaying content is one of its core advantages, which not only concerns user experience but also directly affects the website's SEO performance.The publishing time, update time, view count, and category of the document are often the focus of users' attention, and are also important indicators for search engines to evaluate the timeliness and relevance of content.Fortunately, AnQiCMS provides intuitive and powerful template tags, making the display of this information very simple.

Next, we will explore how to easily display these important document information on your AnQiCMS website.

Display core information on the document detail page

When browsing a specific article or product details, it is usually necessary to display its publication, update time, view count, and category in a prominent position. This can be achieved through AnQiCMS'sarchiveDetailLabel implementation is easy.

Display the publish time (CreatedTime) and update time (UpdatedTime):In AnQiCMSCreatedTimeThe field records the document's publish time,UpdatedTimeThis records the last update time of the document. These two fields store timestamps, and in order to present them in a human-readable format, we need to rely onstampToDateLabel formatting.

For example, if you want to display the publish time in the format of "year-month-day", you can use it like this:

发布于:{{ stampToDate(archive.CreatedTime, "2006-01-02") }}

If you need to be precise to "year-month-day HH:mm", you can do it like this:

更新于:{{ stampToDate(archive.UpdatedTime, "2006-01-02 15:04") }}

HerearchiveRepresents the entire object of the current document,"2006-01-02"are the date formatting standards of the Go language, you can adjust them as needed. It is worth noting that,UpdatedTimeThe display is very important for telling search engines and users that your content is fresh and maintained. If the document content is modified, this time will be updated automatically, andCreatedTimeit will remain unchanged.

Show document view count (Views):Document views are an important indicator of its popularity. In AnQiCMS, views are stored inViewsField, display it very directly:

阅读量:{{ archive.Views }}

You can add units such as 'times', 'reads', etc. after the number according to your design requirements to make the information clearer.

Display the classification of the document:Each document belongs to a category, displaying this information helps users understand the context of the content and makes it easier for them to explore related content. You canarchive.CategoryObject directly retrieves the detailed information of the category, such as the category name and link.

所属分类:<a href="{{ archive.Category.Link }}">{{ archive.Category.Title }}</a>

This method is concise and clear, directly utilizingarchiveDetailThe category information contained in the current document object obtained by the tag.

In summary, on a document detail page, you may see the following layout code:

<article>
    <h1>{{ archive.Title }}</h1>
    <div class="meta-info">
        <span>发布于:{{ stampToDate(archive.CreatedTime, "2006-01-02") }}</span>
        <span>更新于:{{ stampToDate(archive.UpdatedTime, "2006-01-02 15:04") }}</span>
        <span>阅读量:{{ archive.Views }} 次</span>
        <span>所属分类:<a href="{{ archive.Category.Link }}">{{ archive.Category.Title }}</a></span>
    </div>
    <div class="content">
        {{ archive.Content|safe }} {# 注意这里使用了safe过滤器以避免HTML内容被转义 #}
    </div>
</article>

Display core information on the document list page

In the document list page, such as the homepage, category list page, or search results page, we usually cyclically display the brief information of multiple documents. At this time, AnQiCMS'sarchiveListLabels come in handy.

archiveListTags allow you to retrieve document lists based on various conditions such as categories, modules, and recommended attributes. When iterating over these documents, you can access the details of each document just like on the detail page.CreatedTime/UpdatedTime/ViewsAnd category information.

Here is an example of a document list display, which includes publication time, view count, and category:

<div class="document-list">
    {% archiveList archives with type="page" limit="10" %} {# type="page"表示启用分页 #}
        {% for item in archives %}
        <div class="document-item">
            <h2><a href="{{ item.Link }}">{{ item.Title }}</a></h2>
            <div class="item-meta">
                <span>发布于:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                <span>阅读量:{{ item.Views }} 次</span>
                <span>所属分类:
                    {% categoryDetail categoryInfo with name="Title" id=item.CategoryId %}
                    {% categoryDetail categoryLink with name="Link" id=item.CategoryId %}
                    <a href="{{ categoryLink }}">{{ categoryInfo }}</a>
                </span>
            </div>
            <p>{{ item.Description }}</p>
            <a href="{{ item.Link }}" class="read-more">阅读更多</a>
        </div>
        {% endfor %}
    {% endarchiveList %}
    {# 列表页通常会配合分页标签 pagination 使用 #}
    {% pagination pages with show="5" %}
        {# 这里是分页导航代码 #}
    {% endpagination %}
</div>

In this example,itemYesarchiveListEach document object in the loop. We directly accessitem.CreatedTimeanditem.ViewsRetrieve data. For classification information, we useitem.CategoryIdwithcategoryDetaillabels to obtain the classification ofTitleandLink, because in the list loop,item.Categorythe object may not contain the complete classification details by default, usecategoryDetailCan ensure accurate classification information is obtained.

Practical Tips and **Practice

When displaying this information, there are some minor details that can help enhance the professionalism and user experience of the website:

  1. Define the meaning of tags clearly:Add "Published on
  2. Make good use of update time: UpdatedTimeThe presence of auto is particularly important for content that needs to be regularly updated (such as technical tutorials, industry analysis, etc.).It not only indicates the 'freshness' of the content to the user, but is also an important basis for search engines to judge the quality and timeliness of the content.UpdatedTimeWill beCreatedTimeThe same, meaning that the content has not been modified since it was published.
  3. Flexible date formatting: stampToDateLabel supports rich Go language date-time formatting strings, you can display "just now", "a few minutes ago", or a specific year-month-day hour-minute-second according to your design requirements, making your website time display more flexible and diverse.
  4. Categorization navigation guidance:Design the category as a clickable link, which can directly jump to the list page of the category, making it convenient for users to delve into similar content and enhance the internal link structure of the website.
  5. Scheduled release applications:AnQiCMSCreatedTimeFields can be set to future time in the background, achieving scheduled release of documents. This means you can release documents before they are officially launched,