# Paginated gallery possible?

**URL:** <https://discourse.gohugo.io/t/paginated-gallery-possible/14094>\
**Category:** support\
**Tags:** pagination\
**Created:** [September 7, 2018, 9:10am UTC](https://discourse.gohugo.io/t/paginated-gallery-possible/14094 "2018-09-07T09:10:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lx4r](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/lx4r/32/6572_2.png) [@lx4r](https://discourse.gohugo.io/u/lx4r)\
**Post date:** [September 7, 2018, 9:10am UTC](https://discourse.gohugo.io/t/paginated-gallery-possible/14094/1 "2018-09-07T09:10:06Z")

</div>

Hey,  
I’m building a small Hugo site using [this](https://github.com/vickylai/hugo-theme-sam) theme which contains a gallery that shows images files placed in the gallery folder. The gallery partial looks like this:

```auto
{{ 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:

```auto
- - 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](https://gohugo.io/templates/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 😇

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [September 7, 2018, 11:14am UTC](https://discourse.gohugo.io/t/paginated-gallery-possible/14094/2 "2018-09-07T11:14:57Z")

</div>

You cannot use Hugo’s pagination to build your paginated gallery.

---

<div class="post-metadata">

**Author:** ![lx4r](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/lx4r/32/6572_2.png) [@lx4r](https://discourse.gohugo.io/u/lx4r)\
**Post date:** [September 7, 2018, 12:19pm UTC](https://discourse.gohugo.io/t/paginated-gallery-possible/14094/3 "2018-09-07T12:19:51Z")

</div>

Thanks for the help, I’ll look for another solution then.

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [August 13, 2020, 12:11am UTC](https://discourse.gohugo.io/t/paginated-gallery-possible/14094/4 "2020-08-13T00:11:22Z")

</div>

A post was split to a new topic: [How to paginate gallery](https://discourse.gohugo.io/t/how-to-paginate-gallery/27544)

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [August 13, 2020, 12:11am UTC](https://discourse.gohugo.io/t/paginated-gallery-possible/14094/5 "2020-08-13T00:11:31Z")

</div>


