Issue with /projects/ and content type generating

Hi all,

I’m currently using Hugo 0.54.0, but the issue happened on older versions too.

I’ve got a problem with template generation. Content lives under the /projects/ folder both for data and inside theme layouts folder. Structure looks something like that:


themes/mytheme/layouts/projects/list.html (standard listing under /projects/)
themes/mytheme/layouts/projects/taxonomy.html (category page, dynamic code is the same as in list.html)
themes/mytheme/layouts/projects/single.html (single project)

And the example .md file from project

date = "2019-03-19T00:00:00+00:00"
excerpt = "Second Project Excerpt"
projects = ["cat1", "cat2"]
thumb = "/uploads/photo-1511707171634-5f897ff02aa9-small.jpg"
thumb_big = "/uploads/photo-1511707171634-5f897ff02aa9.jpg"
title = "Second Project"

This is content for my second project

The problem is that sometimes when I build new site with Hugo the /projects/ page is getting messed up and instead of projects categories are generated and instead of links to single project links to single categories. Below are the screens from properly generated page and the issue. This doesn’t happen every time, but still I have to check the site after deploy every time to make sure it’s all good.

And lastly this is how list/taxonomy.html file looks like. Both are practically the same, only the main title is different.

{{ define "main" }}
<div class="page-title">
  <div class="container">
    <h1>{{ .Title }}</h1>
<div class="container py-5">
  <div class="row">
    {{ range .Pages }}
    <div class="col-md-4">
      <article class="card mb-5">
        {{ $title := .Title }}
        {{ $permalink := .Permalink }}
        {{ with .Params.thumb }}
        <a href="{{ $permalink }}">
          <img class="card-img-top" src="{{ . | urlize | relURL }}" alt="{{ $title }}">
        {{ end }}
        <div class="card-body">
          <a href="{{ $permalink }}">
            <h5 class="card-title">{{ $title }}</h5>
          {{ with .Params.excerpt }}
            <p class="card-text">{{ . }}</p>
          {{ end }}
          <a href="{{ $permalink }}" class="btn btn-primary btn-sm">More details</a>
        <div class="card-footer">
          {{ range .Params.projects }}
            <a class="btn btn-secondary btn-sm" href="{{ "/projects/" | relLangURL }}{{ . | urlize }}">{{ . }}</a>
          {{ end }}
    </div><!-- .col -->
    {{ end }}
  </div><!-- .row -->
</div><!-- .container -->
{{ end }}

My question is: what is wrong here and why it is generated like that sometimes? Code in my example seems to be pretty basic, I wanted to keep it simple. The issue doesn’t happen every time, but sometimes I need to rebuild the site couple times to make it work.

Any ideas? Maybe there is as issue in the code somewhere or maybe that’s known bug and how Hugo works?

Thanks for any help

Welcome on the Hugo forum! :wave:

It’s hard to tell what’s going on here since your template code looks right. Can it be that your content files miss certain parameters?

For example, the ‘bad example’ misses the thumb images. But your code only add those when thumb is set:

{{ with .Params.thumb }}
<a href="{{ $permalink }}">
  <img class="card-img-top" src="{{ . | urlize | relURL }}" alt="{{ $title }}">
{{ end }}

You probably already looked at this, but without looking at the site’s code I can’t come up with something more helpful. Perhaps someone else has a better idea. :slight_smile:

It’s at least definitely not how Hugo works: given the same input Hugo always renders the same output.

Hi Jura,

thanks for the response.

All parameters are provided, so that can’t be the issue. Tested with and without, problem was still there.


What does your config.toml look like? I notice you have

projects = ["cat1", "cat2"]

in your sample front matter. Are you using projects as a taxonomy? If so, that might be the issue.


here is the code from config.toml:

baseURL = ""
languageCode = "en-us"
theme = "mytheme"
title = "My New Hugo Site"
name = "All fields"
url = "/all-fields/"
weight = 5
name = "Contact"
url = "/contact/"
weight = 4
identifier = "home"
name = "Homepage"
url = "/"
weight = 1
identifier = "posts"
name = "Posts"
url = "/posts/"
weight = 2
identifier = "projects"
name = "Projects"
url = "/projects/"
weight = 3
category = "categories"
project = "projects"
service = "services"
tag = "tags"

Due to the official docs all seems to be fine with the taxonomies (, but you never know. It also happens once in a while, it’s not permanent issue, sometimes /projects/ are generated properly, but sometime I need to trigger the build once again.

File indentation is “flat”, because it’s generated from Forestry, but it doesn’t change/fix/break anything. Tested that too.

Well, you have to choose if /projects/ is supposed to be a section or a taxonomy term. It can’t be both.

Ok, so basically if I want to keep the taxonomy term as project = "projects" I need to change the section to something else e.g.



Both can’t be the same?


changing tax terms to project-cat = "project-cats" ?

Yep. Either of those options should work. your Taxonomy layout also needs to go in a different place, depending on what your taxonomy ends up being called:

Ok, got it. I’ll check it out.

Thanks :slight_smile: