# Weird pagination (can it be done with Hugo?)

**URL:** <https://discourse.gohugo.io/t/weird-pagination-can-it-be-done-with-hugo/19370>\
**Category:** support\
**Tags:** pagination\
**Created:** [June 26, 2019, 3:36pm UTC](https://discourse.gohugo.io/t/weird-pagination-can-it-be-done-with-hugo/19370 "2019-06-26T15:36:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [June 26, 2019, 3:36pm UTC](https://discourse.gohugo.io/t/weird-pagination-can-it-be-done-with-hugo/19370/1 "2019-06-26T15:36:14Z")

</div>

I “so totally” would like a blog website where the following structure takes place:

homepage:

- shows the latest entry full,
- then 4 entries in short (either a list of titles that are linked or the .Summary with `read more` link)
- then a numbered pager (first, before, 1, 2, 3, …, next, last)

list page

- shows paged items (10 per page) without the 5 entries that were listed on the homepage.

Possible? Basically the listpage would have to take a range with the latest 5 items missing to realise this. Is there a way to give this info to the pagination?

---

<div class="post-metadata">

**Author:** ![ju52](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/ju52/32/6749_2.png) [@ju52](https://discourse.gohugo.io/u/ju52)\
**Post date:** [June 26, 2019, 5:26pm UTC](https://discourse.gohugo.io/t/weird-pagination-can-it-be-done-with-hugo/19370/2 "2019-06-26T17:26:04Z")

</div>

You can start with something like in your partial list.html

{{ $paginator := .Paginate .Data.Pages }}  
{{ range $index, $element := $paginator.Pages -}}  
{{ if eq $index 1 }}  
{{ .Content }}  
{{ else }}  
{{ .Render “summary” }}  
{{end}}  
{{- end }}  
{{ partial “pagination” . }}

---

<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:** [June 27, 2019, 12:45am UTC](https://discourse.gohugo.io/t/weird-pagination-can-it-be-done-with-hugo/19370/3 "2019-06-27T00:45:36Z")

</div>

You can configure the pages that you send to the Paginator: [Pagination](https://gohugo.io/templates/pagination/#list-paginator-pages)

> [@davidsneighbour](#):
>
> - shows the latest entry full,
> - then 4 entries in short (either a list of titles that are linked or the .Summary with `read more` link)
> - then a numbered pager (first, before, 1, 2, 3, …, next, last)

Should be fairly straightforward:

```auto
<h1>First:</h1>
{{ range first 1 .Site.RegularPages }}
  <h2>{{.Title}}</h2>
  {{.Content}}
{{ end }}

<h1>Next 4:</h1>
{{ range first 4 (after 1 .Site.RegularPages) }}
  <h2>{{.Title}}</h2>
  {{.Summary}}
{{ end }}

<h1>Paginate:</h1>
<ul>
{{ range (.Paginate ( after 5 .Site.RegularPages ) 3 ).Pages }}
  <li>{{.Title}}</li> <!-- force page size = 3 ^ for testing small number of pages -->
{{ end }}
</ul>

{{ template "_internal/pagination.html" . }}

```

> [@davidsneighbour](#):
>
> list page
> 
> - shows paged items (10 per page) without the 5 entries that were listed on the homepage.

Assuming the above where the first 5 on the homepage are just the latest 5 pages, regardless of content section, otherwise modify accordingly.

```auto
<!-- Get the latest 5 (should be equivalent to the latest 5 on homepage) -->
{{ $latesthome := ( first 5 .Site.RegularPages ) }}

<!-- Get the .Pages belonging to this section that are not in $latesthome -->
{{ $pages := .Pages | complement $latesthome }}

<h1>Paginate {{.Title}}:</h1>

<ul>
{{ range (.Paginate ( $pages ) 3 ).Pages }}
  <li>{{.Title}}</li>
{{ end }}
</ul>

{{ template "_internal/pagination.html" . }}

```

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [June 27, 2019, 2:10pm UTC](https://discourse.gohugo.io/t/weird-pagination-can-it-be-done-with-hugo/19370/4 "2019-06-27T14:10:42Z")

</div>

I am working on implementing this. The first part works fine, but the pagination is leading to the same content with /seite/2/ (/page/2/) in the url. I’ll try my own pagination script.

The pagination documentation is very helpful. Thanks for your help, I will post the end result once I have it working.

---

<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:** [June 27, 2019, 11:51pm UTC](https://discourse.gohugo.io/t/weird-pagination-can-it-be-done-with-hugo/19370/5 "2019-06-27T23:51:50Z")

</div>

> [@davidsneighbour](#):
>
> the same content with /seite/2/ (/page/2/) in the url

Do you mean the “First” and “Next 4” parts?

You could create the `.Paginator` before it is used (discussed in the Building the Navigation section of the pagination docs). Then show that part only on page 1. So:

```auto
{{ $paginator := (.Paginate ( after 5 .Site.RegularPages ) 3 ) }}

<!-- Check if on Page 1 -->
{{ if eq 1 $paginator.PageNumber }}
<h1>First:</h1>
...
<h1>Next 4:</h1>
...
{{ end }}

<h1>Paginate:</h1>
<ul>
{{ range $paginator.Pages }}
  <li>{{.Title}}</li>
{{ end }}
</ul>

...

```

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 28, 2019, 7:36am UTC](https://discourse.gohugo.io/t/weird-pagination-can-it-be-done-with-hugo/19370/6 "2019-06-28T07:36:02Z")

</div>

Also see:

> **[complement](https://gohugo.io/functions/complement/#readout)**
>
> \`collections.Complement\` (alias \`complement\`) gives the elements of a collection that are not in any of the others.
