How to display detailed information of AnqiCMS specific Tag, such as description and Logo, on the front page?

AnqiCMS as an efficient content management system not only provides rich content publishing and management functions, but also offers great flexibility for the display of front-end pages.In website operation, making reasonable use of tags (Tag) can effectively enhance the organization of content, user experience, and search engine optimization (SEO).When users browse to a specific tag, if the page can directly display detailed information about the tag, such as its description and exclusive Logo, it will undoubtedly greatly enhance the professionalism and attractiveness of the page.

Next, we will discuss how to flexibly display detailed information of specific tags, such as descriptions and Logos, on the front page of AnqiCMS.

The role of the tag in AnqiCMS and the backend settings

In AnqiCMS, tags are a powerful content organization tool that allows you to link related content across different categories or models.For example, an article about 'website construction' and an article about 'SEO optimization' can both be tagged with 'marketing strategy', making it convenient for users to find related content through this common theme.

In the background management interface, you can manage all tags of the website uniformly through the 'Document Tags' feature under 'Content Management'.Here, you can create new tags, edit the names of existing tags.It is more important that when editing or adding tags, you can set a 'Tag Description' to elaborate on the meaning of the tag, and also upload a unique 'Tag Logo' to give the tag a stronger visual recognition.These backend configurations are the foundation for displaying rich tag information on our front-end page.Make sure to provide detailed descriptions and upload corresponding Logos for important tags, which is the key first step for the frontend display effect.

Call the tag details in the frontend template

AnqiCMS uses syntax similar to Django template engine, making it intuitive and flexible to call backend data in front-end templates. To display the description and Logo of a specific tag, we need to usetagDetailThis tag. Typically, this information is displayed on the tag detail page (for exampletag/index.htmlortag/list.htmlat the top of this template file) as an overview of the tag.

Firstly, in your tag page template, you can get the detailed information of the current tag throughtagDetailtags.tagDetailTags default to getting the tag ID of the current page, no need to specify an ID separately.

To get the label description information, you can use it like thistagDetailLabel:

<div class="tag-description">
    {% tagDetail with name="Description" %}
</div>

Here,name="Description"Explicitly tell the template engine what we want to get is the "description" field of the current tag. If the tag description contains HTML content, to ensure correct rendering and not to display the original HTML code, you can cooperate withsafeFilter used together, for example{{ tagDetail_description|safe }}.

Similarly, to display the logo image of the tag, you can call it like thistagDetailLabel:

<div class="tag-logo">
    <img src="{% tagDetail with name="Logo" %}" alt="{% tagDetail with name="Title" %} Logo">
</div>

Here,name="Logo"Returns the URL of the label logo image, which you can directly embed into<img>the tag'ssrcproperties. Additionally, to enhance accessibility and SEO, it is recommended to add an imagealtProperty, the content can be the title of a tag. The tag title can also be obtained by{% tagDetail with name="Title" %}.

Combining these segments, a complete tag information display area may look like this:

<div class="tag-header">
    <h1>{% tagDetail with name="Title" %}</h1>
    <div class="tag-details">
        <div class="tag-logo">
            <img src="{% tagDetail with name="Logo" %}" alt="{% tagDetail with name="Title" %} Logo">
        </div>
        <div class="tag-description">
            <p>{% tagDetail with name="Description" %}</p>
        </div>
    </div>
</div>

This code will first display the label's title, followed by the logo image and description text side by side.Through this method, users can have a direct understanding of the subject of the label without having to read the specific content under the label.

**Practical Considerations

  1. Make good use of CSS to beautify: Get the description and Logo of the label, and you can use CSS to format and beautify it, making it consistent with the overall style of the website and enhancing the visual experience.

  2. Graceful degradation handling: If a tag does not have a Logo or description set, the front-end page may appear blank. To avoid this situation, you can add conditional judgment in the template. For example,LogoorDescriptionThe field exists or has a value, and the corresponding HTML element is only rendered when there is content:

    {% set tag_logo = tagDetail_logo %} {# 假设获取Logo到变量tag_logo #}
    {% set tag_description = tagDetail_description %} {# 假设获取Description到变量tag_description #}
    {% if tag_logo %}
        <img src="{{ tag_logo }}" alt="...">
    {% endif %}
    {% if tag_description %}
        <p>{{ tag_description }}</p>
    {% endif %}
    

    In fact,tagDetailThe label will not output content when the field cannot be obtained, so it can be used directly, but explicitly assigning it to a variable and then judging is clearer.

  3. SEO friendly: Set a unique description and high-quality logo for the tab page, which helps search engines better understand the theme of the tab page and may improve its ranking in search results. Make surealtTags and SEO elements are also properly filled.

  4. Page loading performance: Make sure the logo image uploaded is optimized, with moderate size and dimensions, to avoid slow page loading due to large images, which may affect user experience.The 'Content Settings' of AnqiCMS provides features such as automatic image compression and WebP conversion, which can effectively help you optimize images.

By following these steps, you can display the detailed information of specific tags in the AnqiCMS front page in a rich and intuitive way, providing a better browsing experience for visitors, and also adding bricks and tiles to the SEO performance of the website.


Common Questions (FAQ)

What will be displayed on the front page if a Tag does not have a Logo or description? How should I handle it?If a tag does not have a Logo or description,{% tagDetail with name="Logo" %}or{% tagDetail with name="Description" %}This tag will output no content.The area corresponding to the display of this information on the page will be left blank.To avoid the appearance of unattractive blank spaces on the page, you can add conditional judgments in the template and only render the relevant HTML elements when actual content is obtained.For labels without a Logo, you can set a default placeholder image, or hide the description area when there is no description.

2. How to display the document list under the Tag on the detail page at the same time?Display the document list under the Tag on the Tag detail page, you can use the document list provided by AnqiCMS.tagDataListLabel.This tag is specifically used to retrieve all related documents under a specified Tag.It will automatically recognize the current Tag page ID.

{% tagDataList archives with type="page" limit="10" %}
    {% for item in archives %}
        <a href="{{item.Link}}">{{item.Title}}</a>
        <p>{{item.Description}}</p>
    {% endfor %}
{% endtagDataList %}

This will list the first 10 documents under the current Tag and support pagination.

3. Can the URL structure of the Tag page be customized? How to perform pseudo-static optimization?tag-{id}ortags/{filename}.htmlSuch forms can generate more semantically meaningful and SEO-friendly URLs.Ensure that the static rules selected or customized can clearly express the page content, which is helpful for search engines to crawl and understand.