Turn off pagination

In my config.toml I’ve set paginate = 99 because I have fewer than 99 pages and I do not want pagination pages. When I run hugo, the public directory contains a page/1 directory. How do I tell hugo not to create the page directory. Looking at gohugo.io/getting-started/configuration/, the settings that might be related to a solution to this are these:

# Allows you to disable all page types and will render nothing related to 'kind';
# values = "page", "home", "section", "taxonomy", "taxonomyTerm", "RSS", "sitemap", "robotsTXT", "404"
disableKinds = []
 :   
# Pagination
paginate =                    10
paginatePath =                "page"

I tried setting paginate = 0 but that produced this error:

error calling Paginator: ‘paginate’ configuration setting must be positive to paginate

Is there a way to turn off pagination?

Thanks.

Only by not using it in the templates.

Hi bep,

I tried to disable pagination for only “tags” Taxonomy.
In my template I tried

{{ if and (.Paginator) (ne .Name "Tags") }}

With the code above, I managed to hide pagination bar in my tags page.

But Hugo still generates pagination pages for tags.

I also tried a separate tag.terms.html without any reference to Paginator, but it was the same.

How can I disable the generation of tags pages only?

Create ./tags under layout and copy list.html from the _default directory.
Remove paging from the copied templates.

Hi ju52,

I tried your suggestions, but it did not work. I still see /tags/pages/... in the generated site, though there is no . Paginator reference from layouts/tags/list.html (therefore no pagination bar on the page).

This is basically the same as a separate tag.terms.html.

list.html is used to list all tags and to list all pages for a tag.

I use layout/tags/terms.html.html to list all tags - looks like this

 {{ define "main" }}
    <header>	<h1>{{ .Page.Title }}</h1></header>
    <article>
    {{range .Data.Terms.Alphabetical }} 
 	    <a href={{ .Page.RelPermalink }} title="Pages for &quot;{{.Page.Title}}&quot; ">{{.Page.Title}}</a>&nbsp;<sup class=b>{{.Count}}</sup>
	{{ end}}
    </article>
 {{ end }} 

The list of all pages for a tag is rendered with list.html.html
I used this names, bc hugo looks first at it.

Hi, I met with the same problem. So how did you solve this?
I tend to regard this as a bug of Hugo.

Even I replaced the range .Paginator.Pages with range .Pages in terms.html, it still generates pagination pages.

Workaround:

  • Add these lines to config.toml:

    paginatePath = "/../../../../../../../../../../../../../../"
    paginate = 10000000
    
  • Create a build.sh within the project root folder which you will be using for generating the project:

    #!/bin/sh
    rm -rf public
    hugo --gc
    rm -rf public/1
    
  • Execute:

    chmod +x build.sh
    

There you go. Execute ./build.sh whenever you build the project.
[BONUS] I also use tidy to clean up my html files by adding this line to build.sh:

find public -name '*.html' -type f -print -exec tidy --indent true --indent-spaces 2 --tidy-mark false -mq '{}' \;

I faced the same problem, not with tags, but with just pages from a section in a list.html layout. I had a section subdirectory with just one file “1”.

As bep indicated, that’s the use of .Paginator that was causing the issue

I replaced:

{{ range .Paginator.Pages }}`

by:

{{ $section := .Section }}
{{ range where .Pages "Section" $section }}

and it fixed the issue.

(I know that it is not directly related, but that the first post about turning off pagination that comes out, so I thought it might help)