Add Previous and Next links to web content
Customize your web pages to include "Previous" and "Next" links so your readers can move forward and backward between pages with pagination.
Pages that are stored in the same folder display in chronological order based on the firstPublicationDate of each page.
Add Previous and Next template tags
- Create a template:
Select Content Types > All Content Types.
Click on the link in the Label column for any Web Page Base Type.
Note: Pagination links work for web page-derived content types only.
In the Display Templates section, click New template.
Enter a name for the template, such as "Previous Next."
(Optional) Enter a description of the template.
Click Create to open the Edit form.
Click Save.
Tip: Template fields are available only in the plain text editor. Complete the next step in the Source code.
- Enter source code in the template:
In the Display Templates section, click Source in the row of your new template.
Enter the following code in the source field:
<a href="${prevPublication}">Previous Post</a>
<a href="${nextPublication}">Next Post</a>
Tip: By default, clicking Previous on a first page refreshes the page, and clicking Next on a last page refreshes the page. To remove first and last page links, use the following syntax:
<t:if test="isFirstPublication==false"><a href="${prevPublication}">Previous Post</a></t:if>
<t:if test="isLastPublication==false"><a href="${nextPublication}">Next Post</a></t:if>
Click Save.
-
Optional) Customize messages to display in the preview by adding host configurations with the following names:
prevPublicationPreviewMessage
nextPublicationPreviewMessage
-
Click Reports & Tools > Host Configuration Properties.
-
Click the plus icon.
-
Enter a name for your property, such as
prevPublicationPreviewMessage
. -
Enter a value for your property, such as
-
-
(Optional) Preview your links:
-
Click Content Types.
-
In the Display Templates field, find the name of your display template with the links.
-
Click Source in the row of the template.
-
Click the Preview tab.
Tip: Known issues in preview mode will not impact site functionality:
Navigation links do not display for the
isFirstPublication
andisLastpublication
template tags.Navigation links display for other tags, but render a "Problem with your request" page when clicked in the template editor.
-