As an experienced website operations expert, I know that a detailed understanding of each tag (Tag) function in a content management system can bring a qualitative leap in website operation efficiency and SEO performance. Today, let's delve into a very practical template tag in AnQiCMS (AnQiCMS) -prevArchiveand focus on whether it can obtain the previous document'sKeywords(keyword) field.
ExploreprevArchiveTags and document keywords: AnQiCMS fine-grained content linkage
In the template design of AnQi CMS,prevArchiveThe label mainly undertakes the function of realizing the navigation of articles before and after. When a user browses a document (Archive), this label can help website developers easily obtain relevant information about the previous document of the current document, thus providing convenient jump links at the bottom or sidebar of the page, greatly optimizing the user experience and internal content flow.It is like an invisible thread that cleverly connects the series of content on the website.
Document keywords (Keywords) play a crucial role in content operation and SEO optimization.They not only help search engines better understand the theme of the page, but are also an important bridge for users to discover content through search.In the AnQiCMS backend, when we create or edit a document, there will always be a special "document keyword" field for us to fill in, and it supports manual input or selection from a keyword library, and multiple keywords are usually separated by English commas.This fully reflects the SEO-friendly design concept of AnQiCMS.
Then, let's go back to our core question:prevArchiveCan the tag retrieve the information of the previous document?Keywords(keyword) field, what about?
The answer isAffirmative.
According to the official documentation of Anqi CMS,prevArchiveThe tag clearly supports includingKeywordsmultiple important fields. This means that when you useprevArchiveAfter obtaining the object of the previous document, you can directly access itsKeywordsproperties, just like accessing itsTitleorLink.
This feature brings rich imagination and practical value to website operation.For example, you may want to display not only the title and link of the previous article at the end of the current article, but also briefly prompt the keywords of the previous article to help users quickly judge its relevance and decide whether to jump.This is very beneficial for building a more intelligent and user-friendly content recommendation system, or enhancing the on-site SEO relevance layout.
Next, let's look at how to implement this function in the AnQiCMS template with a simple code example:
{# 在文档详情页模板中使用 #}
{% prevArchive prev %}
{% if prev %}
<div class="prev-article-section">
<h3>上一篇:</h3>
<a href="{{ prev.Link }}">{{ prev.Title }}</a>
{% if prev.Keywords %}
<p class="keywords">关键词:{{ prev.Keywords }}</p>
{% endif %}
</div>
{% else %}
<div class="prev-article-section">
<p>没有更早的文档了。</p>
</div>
{% endif %}
{% endprevArchive %}
In the code above, we first use{% prevArchive prev %}Tag to try to get the object of the previous document and name itprev. Then, through a simple{% if prev %}determination, ensure that the previous document indeed exists. If it exists, we can then proceed to{{ prev.Link }}Get the link,{{ prev.Title }}Get the title and the most critical{{ prev.Keywords }}To get the keywords of the previous document. We have also added a{% if prev.Keywords %}The judgment, to avoid displaying an empty line when there are no keywords, is a good template design habit.
Actual application scenarios:
- Enhance user navigation experience:After reading a technical tutorial, the user can decide more quickly whether to review related content by seeing the key words of the previous tutorial.
- Content relevance提示:In a series of articles on a specific topic, displaying the keywords of the previous article can strengthen the relevance between the content, encouraging users to continue exploring.
- SEO internal link optimization:Although
prevArchive主要用于用户导航,但若能将关键词展示出来,也间接提示了内容相关性,对搜索引擎爬虫理解页面结构和主题有所助益。
In short, the Anqi CMS'sprevArchiveThe tag can get the previous documentKeywordsThe field provides content operators with a more flexible and refined content联动 strategy, which helps improve the user experience and overall value of the website.
Frequently Asked Questions (FAQ)
Q1:prevArchiveTags retrieved from comments.KeywordsField, what will be displayed if the keyword is not filled in in the previous document?A1: If the keyword is not filled in in the previous document,prevArchiveObtainedKeywordsThe field will be an empty string. In the template, you can use conditional judgments (such as{% if prev.Keywords %})to control whether to display the field, thus avoiding the appearance of empty 'Keywords:' on the page, improving the user experience.
Q2: BesidesprevArchive,nextArchiveTags can also retrieve the next document.Keywords?A2: Yes,nextArchivewith the tag andprevArchiveSimilar, it is also used to obtain the information of the next document on the document detail page. According to the AnQiCMS document specification, it also supports obtainingKeywordsfield. You can use{{ next.Keywords }}Get the keywords of the next document.
Q3: If the previous document'sKeywordsfield contains multiple keywords, how can I display them separately on the page and make them clickable tags?A3:KeywordsThe field is typically stored as a comma-separated string of multiple keywords.To display them as clickable tags, you need to combine AnQiCMS templates filters and loop tags.You can usesplitThe filter splits the keyword string into an array and then usesforLoop through this array to generate a link for each keyword. For example, you can link to the website's keyword search page or the corresponding Tag list page.