gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
74.63k stars 7.45k forks source link

Pagination doesn't work #1037

Closed philcryer closed 9 years ago

philcryer commented 9 years ago

I cannot get pagination to work, from the docs it sounds like it should be default, but it doesn't and I can't get it to work even when I tell it to in the config. Here is a run of my site (+500) posts, logging to a file and running in verbose mode. First, Hugo version:

$ hugo version
Hugo Static Site Generator v0.13 BuildDate: 2015-02-21T22:02:30-06:00

Next, see that I have pagination in my config

$ head -n10 config.toml
baseurl = "https://fak3r.com"

languageCode = "en-us"
title = "fak3r"

paginate = 10
paginatePath  ="page"

[params]
  sidebartitle = "fak3r"

running Hugo in verbose mode

$ hugo --theme=redlounge --log=true --logFile="/tmp/out" --verbose=true
Logging to /tmp/out
INFO: 2015/04/02 Using config file: /home/phil/devel/fak3r.com-go/config.toml
INFO: 2015/04/02 syncing from /home/phil/devel/fak3r.com-go/themes/redlounge/static to /home/phil/devel/fak3r.com-go/public/
INFO: 2015/04/02 syncing from /home/phil/devel/fak3r.com-go/static/ to /home/phil/devel/fak3r.com-go/public/
INFO: 2015/04/02 found taxonomies: map[string]string{"category":"categories", "tag":"tags"}
0 draft content
0 future content
527 pages created
0 paginator pages created
1005 tags created
51 categories created
in 20068 ms

and finally, the log, showing it didn't paginate anything

$ cat /tmp/out
LOG:   2015/04/02 14:47:26 thatswhyyoualwaysleaveanote.go:174: 0 draft content
LOG:   2015/04/02 14:47:26 thatswhyyoualwaysleaveanote.go:174: 0 future content
LOG:   2015/04/02 14:47:26 thatswhyyoualwaysleaveanote.go:182: 527 pages created
LOG:   2015/04/02 14:47:26 thatswhyyoualwaysleaveanote.go:182: 0 paginator pages created
LOG:   2015/04/02 14:47:26 thatswhyyoualwaysleaveanote.go:182: 1005 tags created
LOG:   2015/04/02 14:47:26 thatswhyyoualwaysleaveanote.go:182: 51 categories created
LOG:   2015/04/02 14:47:26 thatswhyyoualwaysleaveanote.go:182: in 20068 ms

love the "that's why you always leave a note" in there :)

any ideas on the pagination? Thanks, Hugo is a great option for folks that have a long running blog, everything (except for this) is working great, I'm ready to go live!

bep commented 9 years ago

0 paginator pages created tells me that you do not use the paginator feature in your template(s).

See http://gohugo.io/extras/pagination/

I'm pretty sure it works. I implemented it and use it on several sites.

phybros commented 9 years ago

Yeah, you just have to define a paginator at the beginning of your layout:

{{ range .Paginator.Pages }}
   {{ .Content }}
{{ end }}

Then it should generate the pages.

Edit: took out my type != page condition

bep commented 9 years ago

That looks correct, assuming you have any pages with type != page.

I'm afraid it's not possible to debug your situation without a full project that doesn't work.

philcryer commented 9 years ago

Ah, I'm using a theme - so I didn't set up anything in the layout, will take a look - thanks.

bep commented 9 years ago

Nah.

.Paginator.Pages => all pages for that section / taxonomy / or all pages if used on home page

Paginate is used to filter out just the posts of a given criteria, do sorting etc.

Please close this issue if you feel this is resolved.

philcryer commented 9 years ago

Yep, so I can see it's paginating now:

INFO: 2015/04/02 found taxonomies: map[string]string{"tag":"tags", "category":"categories"}
0 draft content
0 future content
527 pages created
52 paginator pages created
1005 tags created
51 categories created
in 57828 ms

but I clearly have the pagination block in the wrong place, because it's breaking the site (css won't load, etc), but the pages are there. So where specifically do I put that code? Into one of the files? I dropped it in the beginning of _layouts/index.html - so that's obvs wrong.

I'll close this - are you guys on gitter, or is IRC/freenode a better place to ask ?s

Thanks!

bep commented 9 years ago

http://discuss.gohugo.io/ or gitter (see link in README)

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.