Templates

Pages of a list

A long list can be split into pages: the first ten posts on /journal/, the next ten on /journal/page/2/, with links between them.

Add paged and a number to a list, and Verso splits it into pages of that many:

{{ each:journal:newest:10:paged }}
  <a href="{{ item.url }}">{{ item.title }}</a>
{{ /each }}

<nav class="row:x-between">
  {{ if:paging.previous }}<a href="{{ paging.previous }}">Newer posts</a>{{ /if }}
  <span>Page {{ paging.number }} of {{ paging.total }}</span>
  {{ if:paging.next }}<a href="{{ paging.next }}">Older posts</a>{{ /if }}
</nav>

The first ten posts are on the page itself, /journal/. The next ten are at /journal/page/2/, then /journal/page/3/, for as many pages as it takes. Each is built from the same page and template; only the list changes.

Where you are

WriteShows
{{ paging.next }}The address of the next page. Empty on the last
{{ paging.previous }}The address of the page before. Empty on the first
{{ paging.number }}This page's number, from 1
{{ paging.total }}How many pages there are. At least 1, even with nothing to list

Use {{ if:paging.next }} and {{ if:paging.previous }} to show each link only when there is somewhere to go.

Rules

  • Say how many go on each page. {{ each:journal:paged }} stops with “Say how many go on each page, like {{ each:journal:10:paged }}.”
  • One split list per template or block, and it must be the outermost list. A list inside it, like each post's tags, is fine.
  • paging. needs a split list. Without one, it stops with a message.
  • Everything else still works. Sorts, filters and skip-1 apply before the list is split, and {{ else }} shows when there's nothing at all.

In a block

A block can hold the split list too, like a journal index dropped onto a page. The page it's on gets the numbered pages, and if more than one block on a page splits its list, the page gets as many numbered pages as the longest needs. In Build a block, choose Split into pages on a list of pages, then add Previous and next pages for the links.

Titles and the sitemap

Pages after the first get “, page 2” after their title, so they read differently in search results and browser tabs. Tag pages can split their lists too. The numbered pages aren't listed in the sitemap.

In the editor

Open /journal/page/2/ and you see that page with the editor of /journal/, so a change to the heading or the intro lands on the page it belongs to.