Today, with the increasing refinement of content management, every detail of a website may affect the reading experience of users.The document's navigation between previous and next articles, as an important part of guiding users to continuously explore the website content, its convenience and fluidity should not be neglected.archivePrevandarchiveNextThese two powerful and intuitive interfaces help us easily implement and optimize this feature.

UnderstandingarchivePrevWitharchiveNextThe core value of the interface

After a user finishes reading an article, they naturally expect to find the next content related to the theme or published around the same time.If the user needs to return to the article list page at this time and manually filter or search to find the next article, this will undoubtedly greatly increase the user's operation cost, reduce reading interest, and even lead to the user leaving the website directly.

The traditional implementation may require us to first obtain the list of all articles under the current category of the article, then iterate through this list to find the position of the current article, and then judge the previous and next articles based on its index.This method not only increases the complexity of the front-end logic, but may also bring performance overhead when the data volume is large.

While the Anqi CMS providesarchivePrevandarchiveNextThe interface is to solve this pain point.它们的设计理念非常直接:你给我当前文章的ID,我直接告诉你它的“上一篇文章”和“下一篇文章”是什么。This greatly simplifies the development process, moving complex search logic to the backend processing, allowing the frontend to focus more on presentation and user experience.

How to apply these two interfaces to optimize the navigation experience

To make full use ofarchivePrevandarchiveNextInterface, we need to perform operations on the article detail page.The basic idea is: when a user accesses an article, obtain the current article's ID, and then call these two interfaces separately to get the information of the previous and next articles.

  1. Get the current document ID:In Anqi CMS, when you go througharchiveDetailthe interface to get the article details, the returned data will contain aidField, this is the unique identifier for the current article. This ID will be used when we callarchivePrevandarchiveNextthe key parameter for the interface.

  2. InvokearchivePrevInterface to get the previous document:to{域名地址}/api/archive/prevSend a GET request and pass the current article'sid. For example:GET /api/archive/prev?id=当前文档IDparameters in the request. After the interface is successfully returned, if there is a previous document,datathe field will contain the previous document'sid/title/url_tokenandlink等信息。we can usetitleas link textlinkas the jump address to build the 'previous article' navigation. ifdatathe field isnullIf so, it means the current article is the first one, and there is no previous content. At this point, we can choose not to display the 'Previous' button, or to display a grayed-out, non-clickable button.

  3. InvokearchiveNextInterface to get the next document:Similarly, to{域名地址}/api/archive/nextSend a GET request, passing in theid. For example:GET /api/archive/next?id=当前文档ID. The data structure of the interface returnedarchivePrevis similar, if there is a next document,dataField will contain itsid/titleandlinkand other information, used to construct the "next article" navigation. Ifdataresponse fornull, it means that the current article is the last one, and there is no next content.

Through these two interfaces, we can easily implement a concise and clear previous/next navigation area at the bottom of the article detail page.For example, you can design an area with the left side displaying 'Previous: [Article Title]' and the right side showing 'Next: [Article Title]', or even further, add elements like thumbnails to make navigation more lively.

Content operation strategy considerations

This simple navigation optimization actually contains profound content operation strategies:

  • Enhance user experience and stickiness:Users usually want to continue reading similar or related content after finishing an interesting article.The intuitive navigation between sections reduces the user's thinking and operations, making the reading process more fluid, thereby increasing the user's dwell time on the website and overall satisfaction.Users may end up browsing more pages instead of leaving after reading one.
  • Optimize on-site SEO and weight transmission:Search engines will discover and understand the relationships between web pages by following links when crawling website content.合理设置的上下篇导航,为搜索引擎爬虫提供了清晰的内部链接路径,有助于提升文章之间的关联性,实现页面权重的有效传递。This is beneficial for the ranking of long-tail keywords and the overall SEO performance of the website.
  • Build content matrix and thematic guidance:For series articles, special reports, or articles published in chronological order, the navigation between the previous and next articles is particularly important.It can guide users to delve deeper into a topic along a predefined path, thereby better constructing the content matrix of the website and enhancing the value and integrity of the content.

Anqi CMS'sarchivePrevandarchiveNextInterface, provides a graceful and efficient way to build a more intelligent, user-friendly content navigation system.By making simple interface calls, we can significantly improve the user experience of the website and bring tangible benefits to the website's content operation.


Common Questions (FAQ)

Q1: If there is no previous or next document, what will the interface return? How should I handle it?A1: If the current document does not have a previous or next document,archivePrevorarchiveNextthe interface'sdatathe field will returnnull. When displaying on the front end, you can judge bydataIs itnullTo decide whether to display the corresponding navigation button, or to grey it out and make it unclickable, providing better user feedback.

Q2: What is the order of the documents found by these two interfaces? Is it limited to the current category?A2:archivePrevandarchiveNextThe interface defaults to searching for the previous and next documents based on the document ID order (usually the sequence of publication, depending on the internal sorting logic of CMS), and...The content will not be automatically limited to the category of the current documentThis means that it may find documents with consecutive IDs but in different categories. If you need to implement navigation between documents within the current category only, it may be necessary to combinearchiveListInterface, obtain the list of all articles under the current category, and then judge the position of the current article in the list in the front-end logic according to the ID of the current article. Thus, find the adjacent articles under the same category.

Q3: Can I customize the display style of the navigation between the upper and lower parts? For example, add thumbnails or summaries?A3: Of course.archivePrevandarchiveNextReturned by the interface.dataThe object contains the document.title/linkas well aslogoorthumbEnglish information.You can freely customize the display style of the navigation using HTML, CSS, and JavaScript based on these returned data, such as showing article titles, jump links, and even adding thumbnails or brief descriptions to enrich the user's selection information.