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"
categories:
  - 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: "http://example.com/"
theme: "foo"
disableHugoGeneratorInject: true
enableEmoji: true
enableRobotsTXT: true
metaDataFormat: "yaml"
googleAnalytics: "UA-XXXX"
ignoreFiles:
  # These are files that are watched over by Webpack
  - src-static\/*\.(js|css)

menu:
  main:
    - Name: "Home"
      Weight: 10
      URL: "/"
    - Name: "Facebook"
      Weight: 20
      URL: "https://www.facebook.com/foo/"

params:
  description: "My blog"
  author: "Foo Bar"
  images:
    - "http://placekitten.com/200/200"
---

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" . }}
  <main>
    {{ range .Paginator.Pages }}
      {{ partial "summary.html" . }}
    {{ end }}
    {{ partial "pagination.html" . }}
  </main>
{{ 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