Hey,
I’m building a small Hugo site using this theme which contains a gallery that shows images files placed in the gallery folder. The gallery partial looks like this:
{{ define "section_content" }}<div class="section" id="content">{{ .Content }}</div>
{{ if .Site.Params.clickablePhotos }}<div class="grid">
{{ $name := .Site.Params.galleryFolder | default "images/"}}
{{ $path := "gallery/" }}
{{ $content := "/content/" }}
{{ $src := (print $path $name) }}
{{ $folder := (print $content $path $name) }}
{{ $files := readDir $folder }}
{{ $previewSubdirectory := .Site.Params.smallImagesSubfolder | default "small/"}}
{{ $previewImagesEnabled := .Site.Params.smallPreviewImages }}
{{ range shuffle $files }}
{{ if not .IsDir }}<div><a href="{{ $src | absURL }}{{ .Name }}">{{ if $previewImagesEnabled}}<img src="{{ $src | absURL }}{{ $previewSubdirectory }}{{ .Name }}" alt="{{ .Name }}"/>{{ else }}<img src="{{ $src | absURL }}{{ .Name }}" alt="{{ .Name }}"/>{{ end }}</a></div>{{ end }}
{{ end }}</div>
{{ else }}<div class="grid">
{{ $name := .Site.Params.galleryFolder | default "images/"}}
{{ $path := "gallery/" }}
{{ $content := "/content/" }}
{{ $src := (print $path $name) }}
{{ $folder := (print $content $path $name) }}
{{ $files := readDir $folder }}
{{ range shuffle $files }}
{{ if not .IsDir }}<div><img src="{{ $src | absURL }}{{ .Name }}" alt="{{ .Name }}"/></div>{{ end }}
{{ end }}</div>{{ end }}
{{ end }}
This is the structure of the gallery folder inside the content folder:
- - gallery
- - - images
- - - - 3_tp.jpg
- - - - 1_tp.jpg
- - - - small
- - - - - 3_tp.jpg
- - - - - 1_tp.jpg
- - - - - 2_tp.jpg
- - - - - 4_tp.jpg
- - - - 2_tp.jpg
- - - - 4_tp.jpg
- - - _index.md
I would love to extend this theme by paginating the gallery so that it only shows X images per gallery page and the user can then click a link to get to the next gallery page. As far as I understood Hugo’s documentation about pagination this is not possible as the items in the pagination have to be pages.
Is that right or is there a way to build my paginated gallery?
Thanks a lot in advance for the help and sorry if this is a stupid question