As an experienced website operations expert, I know that a thorough understanding of each Tag feature in a content management system can bring a qualitative leap in the operation efficiency and SEO performance of the website. Today, let's delve into a very practical template tag in AnQiCMS (AnQiCMS).prevArchive,and focus on whether it can obtain the previous document'sKeywords(keyword) field.
ExploreprevArchivetags and document keywords: Fine-grained content linkage of AnQiCMS
In the template design of AnQi CMS,prevArchiveThe label mainly bears the function of navigating the article before and after.When the user browses a document (Archive), this tag can help website developers easily obtain the related information of the "previous" document, thus providing convenient jump links at the bottom or sidebar of the page, greatly optimizing the user experience and the internal content flow of the website.It is like an invisible line, cleverly connecting the series of content on the website.
Then, let's return to our core issue:prevArchiveLabel can get the previous document?Keywords(Keywords) field?
The answer isaffirmative.
According to the official document of Anqi CMS,prevArchivethe label clearly supports includingKeywordsThe multiple important fields included. This means that when you use the document details pageprevArchivelabel to get the object of the previous document, you can directly access itsKeywordsproperties, just like accessing itsTitleorLinkThe same.
This feature brings rich imagination and practical value to website operation.For example, you may wish to display not only the title and link of the previous article at the end of the current article, but also a brief reminder of 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 take a simple code example to see how to implement this function in the AnQiCMS template:
{# 在文档详情页模板中使用 #}
{% 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 above code, we first use{% prevArchive prev %}Label to attempt 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,{{ prev.Link }}Get link,{{ prev.Title }}Get the title, as well as the most crucial{{ prev.Keywords }}To get the keywords of the previous document. We have also added a{% if prev.Keywords %}The judgment, to avoid displaying empty lines when there are no keywords, which is a good template design habit.
Actual application scenarios:
- Enhance user navigation experience:After reading a technical tutorial, if the user sees a keyword from the previous tutorial, they can decide more quickly whether to review the related content.
- Content relevance hint: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 isprevArchiveThe label can obtain the previous document'sKeywordsThis ability provides more flexible and refined content联动 strategies for content operators, which helps to enhance the user experience and overall content value of the website.
Common Questions and Answers (FAQ)
Q1:prevArchivethe tags you getKeywordsField, what will be displayed if the keyword is not filled in the previous document?A1: If the keyword is not filled in the previous document,prevArchiveThe one obtainedKeywordsThe field will be an empty string. In the template, you can use conditional judgment (such as{% if prev.Keywords %}The field can be controlled to display or not, thus avoiding the appearance of empty 'Keywords:' on the page, which enhances the user experience.
Q2: BesidesprevArchive,nextArchiveTags can also retrieve the next document.Keywords?A2: Yes,nextArchiveTags andprevArchiveSimilar, it is also used to obtain the information of the next document on the document detail page. According to AnQiCMS document specifications, it also supports obtainingKeywordsfields. 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 separately, you need to combine AnQiCMS template filters and loop tags.splitThe filter splits the keyword string into an array and then usesforLoop through this array, generate a link for each keyword. For example, you can link to the keyword search page of the website or the corresponding Tag list page.