Today, every detail of a website may affect the reading experience as content management becomes increasingly refined.Among them, the navigation of the previous and next documents, as an important part of guiding users to continuously explore the website content, its convenience and fluidity should not be ignored.AnQiCMS (AnQiCMS) understands this and providesarchivePrevandarchiveNextThese 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 one related to the topic 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 operational 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 article category, then traverse this list, find the position of the current article, and then determine which article is the previous one and the next one based on its index.This method not only increases the complexity of the front-end logic, but may also bring performance overhead when the amount of data is large.
And the Anqi CMS providesarchivePrevandarchiveNextAn interface is designed to solve this pain point. Its design philosophy is very direct: give me the ID of the current article, and I will directly tell you what the "previous" and "next" articles are.This greatly simplifies the development process, putting complex search logic in the backend processing, allowing the frontend to focus more on display and user experience.
How to apply these interfaces to optimize the navigation experience
Make full use ofarchivePrevandarchiveNextInterface, we need to perform operations on the article detail page. The basic idea is: when a user visits an article, get the ID of the current article, and then call these two interfaces separately to get information about the previous and next articles.
Get the current document ID:In AnQi CMS, when you go through
archiveDetailThe returned data when obtaining the article details through the interface will contain aidField, this is the unique identifier of the current article. This ID will be used to callarchivePrevandarchiveNextthe key parameter of the interface.Invoke
archivePrevTo get the previous document of the interface:To{域名地址}/api/archive/prevSend a GET request and pass the current article'sid. For example:GET /api/archive/prev?id=当前文档ID. After the interface is successfully returned, if there is a previous document,datafield will contain the previous document'sid/title/url_tokenas well aslinkInformation such astitlecan be used as link text,linkas a jump address to build the 'Previous Article' navigation. IfdataField isnullIt means that 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 display a grey, non-clickable button.Invoke
archiveNextThe interface retrieves the next document:Similarly, send{域名地址}/api/archive/nexta GET request with the current article'sid. For example:GET /api/archive/next?id=当前文档ID. The data structure returned by the interface isarchivePrevsimilar, if there is a next document,dataThe field will contain itsid/titleandlinkinformation, used to build the 'next article' navigation. IfdataWithnullis present, 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 up and down navigation area at the bottom of the article details page.For example, you can design an area, with the left side being "Previous: [Article Title]" and the right side being "Next: [Article Title]," or even further, by adding thumbnails and other elements to make navigation more vivid.
strategy considerations for content operation
This simple navigation optimization actually contains a profound content operation strategy:
- Enhance user experience and stickiness:After reading an article of interest, users usually want to continue reading similar or related content.The intuitive navigation between sections reduces the user's thinking and operation, making the reading process more smooth, thereby increasing the user's stay time on the website and overall satisfaction.Users may end up browsing more pages rather than leaving after reading an article.
- Optimize on-site SEO and weight transfer:Search engines, when crawling website content, will discover and understand the relationship between web pages through links.Reasonably set navigation between the previous and next articles, providing clear internal link paths for search engine spiders, which helps enhance the correlation between articles and effectively pass on the page weight.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 a series of articles, special reports, or articles published in chronological order, the navigation between previous and next articles is particularly important.It can guide users to deeply understand a topic according to a preset path, thereby better constructing the content matrix of the website and enhancing the value and integrity of the content.
Of Security CMSarchivePrevandarchiveNextAn interface provides an elegant and efficient way to build a more intelligent and user-friendly content navigation system.By making a simple API call, we can significantly improve the user experience of the website and bring tangible benefits to the website's content operation.
Frequently Asked Questions (FAQ)
Q1: If there is no previous or next document, what will the interface return? How should I deal with it?A1: If the current document has no previous or next document,archivePrevorarchiveNextinterface'sdataThe field will returnnullYou can judge it when displaying on the front end,dataIs itnullDetermine whether to display the corresponding navigation button, or make it gray and non-clickable, to provide better user feedback.
Q2: What order are the previous and next documents searched for by these two interfaces? Are they restricted within the current category?A2:archivePrevandarchiveNextThe interface is based on the order of document ID (usually the sequence of publication time, depending on the internal sorting logic of CMS) to find the previous and next documents, andIt does not automatically limit to the category of the current documentThis means that it may find documents from different categories but with consecutive IDs. If you need to implement navigation between previous and next articles within the current category, you may need to combinearchiveListInterface, retrieve 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, thus finding the adjacent articles in the same category.
Q3: Can I customize the display style of the navigation between pages? For example, add thumbnails or summaries?A3: Of course, you can.archivePrevandarchiveNextThe interface returnsdataThe object contains the document'stitle/link, as well aslogoorthumbInformation. You can use this returned data to freely customize the display style of navigation on the front end, such as displaying article titles, jump links, and even adding thumbnails or brief descriptions to enrich the user's selection information.