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:
content/projects/project1.md
content/projects/project2.md
content/projects/project3.md
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>
</div>
<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 }}">
</a>
{{ end }}
<div class="card-body">
<a href="{{ $permalink }}">
<h5 class="card-title">{{ $title }}</h5>
</a>
{{ with .Params.excerpt }}
<p class="card-text">{{ . }}</p>
{{ end }}
<a href="{{ $permalink }}" class="btn btn-primary btn-sm">More details</a>
</div>
<div class="card-footer">
{{ range .Params.projects }}
<a class="btn btn-secondary btn-sm" href="{{ "/projects/" | relLangURL }}{{ . | urlize }}">{{ . }}</a>
{{ end }}
</div>
</article>
</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
Cheers