Hugo build task makes way too many category pages

I have about about 5575 posts, that’s about 558 paginated pages (10 per page). About 20 of the posts have a category “video”.

After I’ve build the site, and look into public/categories/videos/page, there are 558 pages of paginated content there, whereas it should be only 2 with that pagination, if understand this right. Same goes for all the other categories.

My post FrontMatter looks like this:

author: "Foo Bar"
  - videos
date: 2017-04-22T17:56:07+02:00
description: "Sweet post"
title: "Some Post"

And here’s the config file:

languageCode: "en-us"
title: "Foo Bar"
baseurl: ""
theme: "foo"
disableHugoGeneratorInject: true
enableEmoji: true
enableRobotsTXT: true
metaDataFormat: "yaml"
googleAnalytics: "UA-XXXX"
  # These are files that are watched over by Webpack
  - src-static\/*\.(js|css)

    - Name: "Home"
      Weight: 10
      URL: "/"
    - Name: "Facebook"
      Weight: 20
      URL: ""

  description: "My blog"
  author: "Foo Bar"
    - ""

I’m using the 0.30.2 version.

This is impossible for anyone to debug without seeing the full source.

@bep Okay found the culprit, it’s the layouts/_default/list.html, there I have:

{{ partial "header.html" . }}
    {{ range .Paginator.Pages }}
      {{ partial "summary.html" . }}
    {{ end }}
    {{ partial "pagination.html" . }}
{{ partial "footer.html" . }}

Which gets all the pages, apparently. So it obviously works as it should. But how do I limit the list.html to only show categories when I hit the /categories/videos URL?

You can use the .RelPermalink page variable (or its brother .Permalink) to check what the URL is of the current page that gets rendered.

For example:

{{ if eq (string .RelPermalink) "/categories/videos/" }}
    <!-- Do something specific for that page -->
{{ end }}
1 Like