Permalink are same on pagination pages

Not sure if this is by designed or a bug, paginaton pages’ Permalink (RelPermalink) are same.

// layouts/index.html
{{ range .Paginator.Pages }}
  {{ warnf "%s" .Title }}
{{ end }}

{{ warnf "[%s] page number: %d" .Permalink .Paginator.PageNumber }}

paginate is set as 1.

hugo

WARN  A
WARN  [https://example.org/] page number: 1
WARN  B
WARN  [https://example.org/] page number: 2
WARN  C
WARN  [https://example.org/] page number: 3

Mind the context

The loop renders index html three times,

but your second warn is outside any paginator loop

so .Permalink has the index.html as context

Yep, however I’m questioning about the pagination pages, the second warn should be correct.

Page Permalink
https://example.org/ https://example.org/
https://example.org/page/2 https://example.org/
https://example.org/page/3 https://example.org/

I’m not sure if the pagination page’s Permalink should be similar the follows, or it’s theme author’s duty to use .Paginator.URL instead of Permalink in this case.

Page Permalink
https://example.org/ https://example.org/
https://example.org/page/2 https://example.org/page/2
https://example.org/page/3 https://example.org/page/3

What you call “Pagination Page” is IMHO not available

from the docs at: Paginate | Hugo

Pagination is the process of splitting a list page into two or more pagers, where each pager contains a subset of the page collection and navigation links to other pagers.

So at this stage

  • there is no Page but only ONE Pager object which offers Pager methods | Hugo to deal with it’s pageSets.

  • the current context “.” of the rendered Page (index.md) is unchanged.

    You already noticed that by using .Paginator.PageNumber and not just .PageNumber in your warnf Statement.

This is a Design/Implementation decision

There are plenty of reasons I can think of why that has been done… but I wont guess here

1 Like

See https://github.com/gohugoio/hugo/issues/4507.

This is one of the top 10 upvoted issues.

1 Like

If you do this, make sure you do it AFTER paginating the page collection.

1 Like

This may be a minor issue for some embeded templates, such as Twitter cards, I guess.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.