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

Hi, what about providing an option for controling this behavior? I’d like to disable this for

  1. Reducing the number of files, Cloudflare Pages has a hard limits of files (up to 20k), those alias pages account for 20% of the number of pages (including paginations) on my site.
  2. Saving a little bit of build time.

Since those aliases seems not much affect for my websites, it’d would be great to have an option to not generate them.

Yea, that would make sense.

Could you create a GitHub issue?

1 Like

Thanks, created, Option to not generate aliases for first page of pagination pages · Issue #12572 · gohugoio/hugo · GitHub.

1 Like