Standard article navigation
Many help centers present a list of articles within the current section on the Article page. The Article Navigation extension can compliment this approach, giving visitors direct access to the previous and next article as defined by your content authors. This is perfect when your articles have some inherit ordering, as there’ll be no confusion as to what a visitor should read next.
The links will inherit the overall style of the theme as defined in your theme settings. Additional control is provided through extension options and you can even create your own fully custom templates. Using custom templates, previous and next article links can be presented as simple buttons or include information from the articles themselves, like titles and excerpts.
Custom article navigation
Because the layout and appearance of the links themselves can be fully customized using templates, you can tailor them to your specific use-case.
For more examples, take a look at our Article Navigation patterns.
Creating article navigation links
Our themes allow you to add article navigation links to article pages using the Article navigation setting in the Article page elements setting group. Once a style other than None has been selected, the article navigation links will appear below your article content.
The Article Navigation extension is bundled into all of our themes by default, so you can start using it straight away. You can find the source code for the extension within the extensions.(min.)js
file in the theme’s Assets folder.
Use data-element="article-navigation"
on an element to create a dynamic article navigation element:
<div data-element="article-navigation" data-article-id="{{article.id}}"></div>
If used outside of the Article page, you must provide an article ID using the data-article-id
attribute.
If data attributes are used you will need to ensure that the allow unsafe HTML setting is enabled within Zendesk Guide.
The Article Navigation extension can be instantiated against a element using JavaScript:
<div id="article-navigation"></div>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', () => {
new ArticleNavigation(document.getElementById('article-navigation'), {
articleId: {{article.id}},
// Options go here
});
});
</script>
Options
Name | Type | Default | Description |
---|---|---|---|
articleId | string number null | null | The ID of the current article. |
labels | array | [] | The label(s) to filter articles by. |
properties | array | See below | The object properties from the REST API response to pass to the templating function. |
template | string null | null | The name of the template to use. |
templateData | object | {} | Additional data to expose to the templating function. |
The following article properties are passed to the templating function by default:
id
title
html_url
position
promoted
draft
The following section and category properties are required by the extension to sort the collection of articles:
section_id
category_id
Events
Class | Properties |
---|---|
articleNavigation:render | Fires when the article list has been rendered. |