The error message invalid memory address or nil pointer dereference suggests you are trying to access a nil value. Perhaps a nil.Paginator. So, my suggestion would be to check that you are passing the correct context to the partial. Maybe wrap the .Paginator code in a with to make sure it exists before trying to access .Paginator.TotalPages.
Seriously?
I try to understand why it’s not run. And I wrote exactly what I modified to attempt to use ‘paginator’.
1/ modification config.toml to add: [params.pagination]
2/ modification into partials/list.html, as: <footer>{{ partial "pagination.html" . }}</footer>
3/ the pagination.html into partials, as view abowe.
I try to apply what Hugo doc say, but I have not good results!
Since I’m using Bootstrap, I even tried to add that: {{ template "_internal/pagination.html" . }}
as it’s wrote into doc pagination, in first line into my partial pagination. With same bad result!
There’s something I’m not understand; certainly because of the “language barrier”, but what?!
What are you trying to do here? Anything under params in config.toml is custom parameters. It is not part of the official pagination documentation.
Where in list.html? If you are inserting this inside a range, for example, the dot would have a different value.
Like I said above, the error message implies that you are trying to access a nil value. So wrap your code in a with block to make sure it evaluates only if it is not nil.
Your pagination partial has a few more errors, where you use .Permalink (see your line 6-8 as an example).
{{ with $page.First }}
... {{ .Permalink }} ... <!-- wrong -->
{{ end }}
.First is a Pager, not a .Page. It does not have a .Permalink; use .URL instead.
So put these together:
{{ $paginator := .Paginator }}
{{ with $paginator }} <!-- wrap in a with block -->
{{ if gt .TotalPages 1 }}
{{ with .First }}
{{ .URL }} <!-- use .URL instead of .Permalink -->
{{ end }}
{{ end }}
{{ end }}
Now, my paginator run correctly (into my git repository).
But, I’m not understand how to modify my code to display n links to articles into my default list.html, to match with page number ?!
As you can see, on my git repository, my code is in two distincts parts.
into the partials list.html, I have a range to display all informations about articles (title, description, tags, etc).
and after the paginator, into footer html.
Normally, the paginator display only the numbers of pages, and permit to browse page after page. But, as I wrote my code, all articles are “published” - if the section had 10, or 30 articles, all informations about them are displayed, not segun the number page!
I known: I’m having trouble expressing in English what I mean!
I thought that using paginator would display x items according to the pagine variable (customized or not into config.toml; by default, 10). But, as I wrote, it’s separated!
How I can modify my code to display the x items segun page 1, page n?