As a senior CMS website operation personnel in the security industry, I am well aware of the importance of content in attracting and retaining users.Effective content management and a graceful user experience are the foundation of a successful website.In AnQiCMS, the flexible template tag system is the key to achieving this goal.Today, I will introduce to you in detail how to use the template tags of AnQiCMS to cleverly obtain the previous and next articles as well as related documents, thereby optimizing your content layout, enhancing user experience, and improving the SEO performance of the website.
Optimize user navigation: Get the previous document
On the article detail page, providing a link to the "previous" document is an important way to enhance the user's reading experience and page stay time.By guiding users to browse more content within the site, we can effectively reduce the bounce rate and provide the search engine with a richer internal link structure.
AnQiCMS provides intuitiveprevArchiveThe tag to get the previous content of the current document. This tag does not require any parameters, and it will intelligently retrieve the previous document that meets the conditions according to the publication time or ID of the current document.
You can use the following method to call the data of the previous document in your article detail template:
{% prevArchive prev %}
<div class="article-navigation prev-article">
{% if prev %}
<a href="{{ prev.Link }}" title="{{ prev.Title }}">
<img src="{{ prev.Thumb }}" alt="{{ prev.Title }}" class="nav-thumb" />
<span class="nav-title">上一篇: {{ prev.Title }}</span>
</a>
{% else %}
<span class="no-prev-article">没有了,这已是第一篇</span>
{% endif %}
</div>
{% endprevArchive %}
Here, prevThe variable will contain the details of the previous document, such asId(Document ID),Title(Title),Link(Link),Thumb(Thumbnail) etc. By a simpleifJudge, you can elegantly handle the case where there is no previous document, ensuring the friendly display of the page.
Guide the user to delve deeper: get the next document.
The link in the next document plays the role of bridging the previous and next documents.It encourages users to continue exploring your website, forming a coherent reading path.This continuity is not only beneficial to users, but also indicates to search engines that your website has rich and well-organized content.
In AnQiCMS,nextArchiveThe tag is a special tool for obtaining the next document. AndprevArchiveLike the tag, it also does not require additional parameters, and it will automatically locate the next content of the current document.
This is the template code example to get the next document.
{% nextArchive next %}
<div class="article-navigation next-article">
{% if next %}
<a href="{{ next.Link }}" title="{{ next.Title }}">
<span class="nav-title">下一篇: {{ next.Title }}</span>
<img src="{{ next.Thumb }}" alt="{{ next.Title }}" class="nav-thumb" />
</a>
{% else %}
<span class="no-next-article">没有了,这已是最后一篇</span>
{% endif %}
</div>
{% endnextArchive %}
nextThe variable will carry all the available fields of the next document, allowing you to flexibly display titles, links, thumbnails, and more information.Reasonably arrange these navigation elements, it will greatly enhance the user's browsing depth on your website.
Expand your reading horizon: get related documents.
The recommendation of relevant documents is an indispensable part of content marketing and user experience strategy.It can recommend more content that the user may be interested in based on the theme of the current article, effectively extending the user's session duration and guiding the user to discover the deep value of the website.
In AnQiCMS, obtaining related documents is not through an independent 'related documents' tag, but through flexiblearchiveListtags, combined with itstype="related"Parameters to implement. This design allows you to customize the retrieval logic of relevant documents according to different requirements.
The following is the template code and parameter description for retrieving relevant documents.
<div class="related-articles">
<h3>相关推荐</h3>
<ul>
{% archiveList archives with type="related" limit="5" %}
{% for item in archives %}
<li>
<a href="{{ item.Link }}" title="{{ item.Title }}">
<img src="{{ item.Thumb }}" alt="{{ item.Title }}" class="related-thumb" />
<span class="related-title">{{ item.Title }}</span>
</a>
<p class="related-description">{{ item.Description|truncatechars:80 }}</p>
</li>
{% empty %}
<li>暂无相关文档。</li>
{% endfor %}
{% endarchiveList %}
</ul>
</div>
archiveListTags are being used.type="related"At that time, it will automatically retrieve relevant content from the current document. You can further refine the matching logic of the relevant documents through the following parameters:
limit: Used to specify the number of relevant documents to display, for examplelimit="5"Will display 5 articles.like: This parameter is the key to customizing the relevance matching rules.- When set to
like="keywords"When, the system will match relevant documents based on the keywords of the current document, recommending content similar to the keywords. - When set to
like="relation"When, the system will only display in the background document editing interface, the content you manually specify as 'related documents'. - If not specified
likeThe parameter, the system will default to trying to obtain the document closest to the current document in the same category as a related recommendation.
- When set to
archivesHere is a document list array, you can iterate over it and access eachitemofId/Title/Link/Thumb/DescriptionThe fields are used to display relevant content. Reasonably using these parameters can build a highly personalized and accurate recommendation module for relevant content.
Summary and **practice**
By skillfully utilizing the AnQiCMS providedprevArchive/nextArchiveandarchiveList(type="related"These three types of template tags allow website operators to greatly enhance the user experience and content value of the site.These features provide solid technical support for your content strategy, whether it is to guide users in coherent reading or to expand their content discovery path.
In actual operation, I suggest that you always pay attention to the following points:
- Consistency in designEnsure that the link styles of the previous, next, and related documents match the overall design style of your website, providing a smooth visual experience.
- Information integrity: Besides the title and link, try to display thumbnails or brief descriptions to help users quickly determine whether to click.
- Real-time feedbackUsing the AnQiCMS update mechanism, ensure that these navigation links always point to the latest and most accurate content.
By making these meticulous optimizations, you can not only keep users on your website longer, but also bring more exposure and conversion opportunities for your content.
Frequently Asked Questions (FAQ)
Q1: Why did I use in the article detail pageprevArchiveornextArchiveThe tag does not show the link to the previous or next document?
A1: There are usually several reasons for this. First, check if the current document contains a 'previous' or 'next' document that meets the criteria.This means that there must be other documents in the same category as the current document, and their publication time or ID must be before or after the current document.If the current document is the first or last in the category, the corresponding link will not be displayed.In addition, please make sure that all documents have been published, draft or unpublished documents will not be retrieved by these tags.
Q2: I want toarchiveListHow can I control the relevance of the "related documents" displayed in the tag?
A2: Of course.archiveListThe tag is intype="related"mode, it provideslikeParameters for defining the relevance of parameters. You can setlike="keywords", so that the system can automatically match similar documents based on the keywords of the current document; or setlike="relation"This will only display the documents you manually associated while editing documents in the background. If you have not set anylikeParameter, the system will default to recommending adjacent documents under the same category. Choose the one that best fits your content strategy.likeValue, it can significantly improve the accuracy of recommendations.
Q3: Are these navigation links (previous, next, related documents) displayed in a fixed style? Can I customize their appearance?
A3: AnQiCMS template tags are only responsible for providing data and do not interfere with the display style of the front end.This means you have complete freedom to customize the layout and appearance of these links through HTML and CSS.You can add custom HTML structure, CSS class names, and even use JavaScript to achieve richer interactive effects as needed, to perfectly integrate into your website design.