Edit on GitHub
Jump to docs navigation

Templating / Paging content

Note: You are currently reading the documentation for Bolt 4.0. Looking for the documentation for Bolt 5.2 instead?

When you have more records than you'd like to display on one page, Bolt will paginate your records. To display the pager, add a pager function.

{% setcontent entries = "entries" latest limit 25  %}

{% for entry in entries %}
    {{ entry.title }}
{% endfor %}

{{ pager() }}

Number of records per page

Number of records per page on listing pages

To configure the number of records per page on a listing page, set the listing_records option for the ContentType in contenttypes.yaml:

    pages:
        name: Pages
        singular_name: Page
        ...
        listing_records: 10 

If there are more than 10 pages, the content will be paginated.

Number of records per page using setcontent

If you're using setcontent to fetch records, you can limit the number of records per page by using the limit directive:

{% setcontent pages = 'pages' limit 10 %}
{{ pager(pages) }}

Displaying the pager

To show the pager, use the pager function in your twig template:

{{ pager() }}

Pager templates

Bolt comes with three partial templates for displaying the pager:

For example, use the following to render the Bulma pagination component:

{{ pager(template='@bolt/helpers/_pager_bulma.html.twig') }} 

If you'd like to define your own pager from scratch, just copy /vendor/bolt/core/templates/helpers/_pager_basic.html.twig to your own theme folder, and rename it to something like mypager.twig. Then, pass the name as an extra parameter to the pager function:

{{ pager(template='mypager.twig) }}

Pager options

Parameter Description
records optional The records to paginate. Default on a listing page are the listing records.
template optional The twig template used to render the pager. By default, use Bolt's basic pager.
class optional An optional class name. Default is pagination.
surround optional Specifies how many items to show around the current page. Default is 3.


Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.