How to limit the Number of links in pagination

By default there are as many as 9 buttons (first, prev, slots 1-5, next, last) in Hugo’s internal pagination template. But there’s an alternate ‘terse’ format that reduces that to a maximum of 7 buttons (first, prev, slots 1-3, next, last). To use the alternate format–

  1. Add the code below to your templates if you’re using the internal pagination.
{{ template "_internal/pagination.html" (dict "page" . "format" "terse") }}
  1. Otherwise, Create a custom pagination file in ./layouts/partials folder, let’s call it pagination.html.
    • Open Hugo’s internal pagination template.
    • Copy the code before/above {{/* Format: default and the code from {{/* Format: terse to the pagination.html file.
    • Use the file in your templates as follows: {{ partial "pagination.html" (dict "page" . "format" "terse") }} .