Skip to content
This repository has been archived by the owner on Jul 5, 2021. It is now read-only.

Page lists broken in various theme demos in 0.57.0 #678

Closed
onedrawingperday opened this issue Aug 14, 2019 · 18 comments
Closed

Page lists broken in various theme demos in 0.57.0 #678

onedrawingperday opened this issue Aug 14, 2019 · 18 comments

Comments

@onedrawingperday
Copy link
Contributor

As stated in gohugoio/hugo#6153 Hugo 0.57.0 has a breaking change since now:

home.Pages work like the other sections

Also due to gohugoio/hugo#6154 now:

.Pages include the sub sections

The above breaking changes were made for developing new features like Cascading Front Matter and will be also needed in the future.

However during local testing with Hugo 0.57.0 I noticed that plenty of theme demos currently on the showcase use .Data.Pages or just .Pages to render lists (particularly on the index page) and as a result the list pages of these themes now look weird.

There is already at least one issue in the wild about a broken homepage in a theme's repo.

Perhaps we should communicate this breaking change through Hugo's official twitter account?

Also what are your suggestions about affected themes and their demos?

cc: @digitalcraftsman and @bep

@kakawait
Copy link
Contributor

I'm theme creator and I'm part of theme that was breaks during update to 0.57 as you can see from my issue kakawait/hugo-tranquilpeak-theme#371

Moreover even after reading release note and both issues. I'm not totally sure how to fix the thing to get the old behavior. I tried many thing with and without .RegularPages but without success

@bep
Copy link
Member

bep commented Aug 14, 2019

@kakawait the old behaviour = .Site.RegularPages for the home page.

@onedrawingperday
Copy link
Contributor Author

onedrawingperday commented Aug 14, 2019

@bep The theme author is using pagination on the home page. When changing line 12 of /layouts/index.html to:
{{ $paginator := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections) 5 }
I get an empty list with no ERROR.

Same with:
{{ $paginator := .Paginate (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) 5 }}

I also tried changing line 13
{{ range $paginator.RegularPages }}
and
{{ range $paginator.Site.RegularPages }}
but these throw ERRORs like:
<$paginator.RegularPages>: can't evaluate field RegularPages in type *page.Pager

@bep
Copy link
Member

bep commented Aug 14, 2019

This:

{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}

Translates to:

{{ $paginator := .Paginate (where .Site.RegularPages "Type" "post") }}

@bep
Copy link
Member

bep commented Aug 14, 2019

I will revisit these problems sometime tomorrow. You can maybe hold off on updating the theme site until the dust has settled.

@onedrawingperday
Copy link
Contributor Author

onedrawingperday commented Aug 14, 2019

This:

{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}

Translates to:

{{ $paginator := .Paginate (where .Site.RegularPages "Type" "post") }}

@bep Sure but me and @digitalcraftsman want to encourage theme authors to use mainSections so that users have flexibility.

We've been doing the above for a while now with theme submissions and we plan to put it in writing for #668

Anyway for the time being I suggest that we wait until/if these issues are addressed before we update the Hugo version that the themes showcase uses when deployed on Netlify.

@ldeso
Copy link

ldeso commented Aug 15, 2019

This solution works for me:

{{ $paginator := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections) }}

However it only works after setting the main section explicitly in the theme parameters:

[params]
mainSections = ["posts"]

@onedrawingperday
Copy link
Contributor Author

onedrawingperday commented Aug 15, 2019

However it only works after setting the main section explicitly in the theme parameters

Thanks for reporting this.

We shouldn’t need to manually specify the mainSections in the config since it’s supposed to be an internal parameter.

cc: @bep

@bep
Copy link
Member

bep commented Aug 15, 2019

See gohugoio/hugo#6217

And I'm sorry about this noise. We would not have done it if we didn't think it was really the best. We could probably have dropped this home.Pages change, but since we had to introduce some other related breaking changes, I thought it was better to take all the pain at once ...

The motivation for this is maybe not obvious, but having the home.Pages behave totally different from all the other pages makes it incredibly hard to reason about in the templates when building navigation etc. It behaved this way because of historical reasons, I feared changing it because it would break stuff -- in retrospect it would been better to change it 2 years ago ...

@kakawait
Copy link
Contributor

I'm not totally sure how to fix the thing to get the old behavior

My bad I don't know why but I was editing _default/list.html rather than index.html... That why I did not succeed anything.

.Site.RegularPages works now when putting on correct file.

I just have to check what to do with _default/list.html because I also have something like

{{ $paginator := .Paginate (where .Data.Pages "Type" .Type) }}

@bep
Copy link
Member

bep commented Aug 15, 2019

What you can do is something like:

{{ $pages := .Pages }}
{{ if .IsHome }}
{{ $pages = .Site.RegularPages }}
{{ end }}
{{ $paginator := .Paginate $pages }}

martignoni added a commit to martignoni/blog.martignoni.net that referenced this issue Aug 15, 2019
martignoni added a commit to moodlebox/hugo-moodlebox-theme that referenced this issue Aug 15, 2019
@kakawait
Copy link
Contributor

{{ $paginator := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections) }}

I don't know if it can help but that thing work with Hugo Static Site Generator v0.56.3/extended darwin/amd64 BuildDate: unknown but not with Hugo Static Site Generator v0.57.0-9B00E647 darwin/amd64 BuildDate: 2019-08-14T08:05:40Z

@onedrawingperday
Copy link
Contributor Author

onedrawingperday commented Aug 15, 2019

@bep I just tested the latest commit gohugoio/hugo@8ddc8a7 and I confirm that the logic of mainSections is fixed.


To the theme authors who appear to reference this issue in various commits, please note that the recommended way to create lists for the homepage and other sections for Hugo themes is the use of mainSections to ensure that users have flexibility.

The above fix will be released in the next version of Hugo in the coming days, so please make the following changes to your themes:

@kakawait Please change line12 of github.com/kakawait/hugo-tranquilpeak-theme/blob/master/layouts/index.html and line 13 of kakawait/hugo-tranquilpeak-theme/blob/master/layouts/_default/list.html to:
{{ $paginator := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections) }}

@wilsandbrink Please change lines 4-5 of github.com/panr/hugo-theme-terminal/blob/master/layouts/_default/list.html to:
{{ $paginator := .Paginate (where .Site.RegularPages "Type" .Type) }}

Also you may want to track issue #668 because soon we will update the theme guidelines for this repo.

@kakawait
Copy link
Contributor

@kakawait Please change line12 of github.com/kakawait/hugo-tranquilpeak-theme/blob/master/layouts/index.html and line 13 of kakawait/hugo-tranquilpeak-theme/blob/master/layouts/_default/list.html to:
{{ $paginator := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections) }}

@onedrawingperday Sorry but I really don't understand why should I apply that change on _default/list.html (OK for index.html) because _default/list.html is used to display list of content (captain obvious) for a given section. But this section is dynamic/relatif.

I mean default/list.html is used during, for example, http://localhost:1313/posts/ or http://localhost:1313/docs/

However if I apply your change (if mainSections = ["posts"]) when browsing http://localhost:1313/docs I'll see posts instead of content from docs.

We could at least change

{{ $paginator := .Paginate (where .Data.Pages "Type" .Type) }}

to

{{ $paginator := .Paginate (where .Site.RegularPages "Type" .Type) }}

but I still sure that type should come from .Type value inside _default/list.html

martignoni added a commit to martignoni/blog.martignoni.net that referenced this issue Aug 16, 2019
@onedrawingperday
Copy link
Contributor Author

@kakawait Sorry I am busy and I haven't looked at it properly but you are right.

The mainSections is meant for the homepage. Use your second code block for _default/list.html because it is preferable:

{{ $paginator := .Paginate (where .Site.RegularPages "Type" .Type) }}

@onedrawingperday
Copy link
Contributor Author

This issue will continue in #682 due to the sheer scale of it.

Vimux added a commit to Vimux/Binario that referenced this issue Aug 17, 2019
Hugo 0.57 breaks mainSections logic and how the home section works.
Switch to .Site.RegularPages for the home page paginator to restore old
behavior.

Fix #13

See gohugoio/hugoThemes#682,
gohugoio/hugoThemes#678,
gohugoio/hugo#6153
Vimux added a commit to Vimux/Binario that referenced this issue Aug 17, 2019
Hugo 0.57 breaks mainSections logic and how the home section works.
Switch to .Site.RegularPages for the home page paginator to restore old
behavior.

Fix #13

See gohugoio/hugoThemes#682,
gohugoio/hugoThemes#678,
gohugoio/hugo#6153
htr3n added a commit to htr3n/hyde-hyde that referenced this issue Aug 19, 2019
This should fix the issue with Hugo's breaking changes since v0.57 as mentioned in gohugoio/hugoThemes#678.
- adjusted post list for Hugo v0.57.0
Credits: @jvalecillos.
henryiii added a commit to henryiii/beautifulhugo that referenced this issue Aug 19, 2019
balaramadurai added a commit to balaramadurai/hugo-travelify-theme that referenced this issue Aug 20, 2019
gohugoio/hugoThemes#678 (comment)

.Pages and .Data.Pages become .Site.RegularPages

The community is good enough to remind me to update these!! Kudos to
them :)
fredliang44 added a commit to fredliang44/hugo-theme-refine that referenced this issue Sep 7, 2019
nickmurison added a commit to nickmurison/hugo-theme-casper that referenced this issue Oct 31, 2019
diemol added a commit to SeleniumHQ/seleniumhq.github.io that referenced this issue Nov 9, 2019
nankeen pushed a commit to nankeen/hyde-hyde that referenced this issue Apr 22, 2020
…57.0

This should fix the issue with Hugo's breaking changes since v0.57 as mentioned in gohugoio/hugoThemes#678.
- adjusted post list for Hugo v0.57.0
Credits: @jvalecillos.
@craigmpeters
Copy link

I am confused, I just have a link to posts now on my homepage, and nothing outlines how to fix this. Why is a breaking change added to a 0.X version, this should have increased the version to 1.X

@onedrawingperday
Copy link
Contributor Author

See #682

@gohugoio gohugoio locked as resolved and limited conversation to collaborators May 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants