Pagination seems to create Aliases

I’m following up on this thread about Aliases showing up in output even though they are not being used.

The issue seems to be related to pagination. Removing pagination from my project removes Aliases from appearing in the output.

Here’s my code.

Layout/products/list

{{range ((.Paginator 4).Pages.ByDate.Reverse)}}
 {{.}}
{{end}}

{{if gt .Paginator.TotalPages 1}}
  {{if .Paginator.HasPrev}}
    <a href="{{if .Paginator.HasPrev}}{{.Paginator.Prev.URL}}{{end}}">Previous</a>
  {{end}}
  {{if .Paginator.HasNext}}
    <a href="{{if .Paginator.HasNext}}{{.Paginator.Next.URL}}{{end}}">Next</a>
  {{end}}
{{end}}

Output - Aliases = 1

+------------------+----+
  Pages            | 92  
  Paginator pages  | 14  
  Non-page files   |  0  
  Static files     | 16  
  Processed images |  0  
  Aliases          |  1  
  Sitemaps         |  1  
  Cleaned          |  0  

If I remove pagination:

Output - Aliases = 0

+------------------+----+
  Pages            | 92  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     | 16  
  Processed images |  0  
  Aliases          |  0  
  Sitemaps         |  1  
  Cleaned          |  0 

Thoughts? :upside_down_face:

It creates an alias from /page/1 for every paginator.

2 Likes

Aha. So that means nothing is wrong. Thanks.

The idea behind this is, that it enables you to have a link like /page/{{ pagenumber }} somewhere in a shortcode or template and don’t need to think about the first page redirect, even if the post number is lower than what would require pagination. It might not be a feature you need but someone out there has use of it. “Hugo does it all” :slight_smile:

I think my main thought behind it was to make it simpler to implement client side infinite scrolling by just looping from 1 until 404.

1 Like