Paginator a-z

I’m using a paginator for a CLI command docs library and it works great but there’s been a request to group / display the buttons as A-Z instead of numbered pages. How would I best do that?

It sounds like you’re trying to build a glossary. There are a few ways to approach this. Perhaps the simplest is to use Hugo’s taxonomy system.


glossary = 'glossary'

example content

title = 'Apple'
date = 2021-01-01T00:00:00-00:00
draft = false
glossary = 'a'


{{ define "main" }}
  <h1>{{ .Title }}</h1>
  {{ .Content }}
  {{ range .Pages }}
    <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
  {{ end }}

  <ul class="pagination">
    {{ range (site.GetPage "/glossary").Pages.ByTitle }}
      {{ if eq $.RelPermalink .RelPermalink }}
        <li class="page-item active">
          <a class="page-link" aria-current="page" aria-label="Page {{ .Data.Term }}" role="button" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
      {{ else }}
        <li class="page-item">
          <a class="page-link" aria-label="Page {{ .Data.Term }}" role="button" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
      {{ end }}
    {{ end }}

{{ end }}


git clone --single-branch -b hugo-forum-topic-40922 hugo-forum-topic-40922
cd hugo-forum-topic-40922
hugo server

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.