Hello, I’m having an issue where the hugo interpreter occasionally displays this list.html template instead of terms.html for a given taxonomy. My file structure is as follows:
/content-1
|–_index.md
|–subcontent-1.md
|–subcontent-2.md
/content-2
|–_index.md
|–subcontent-1.md
|–subcontent-2.md
When the error occurs, the subcontent files are rendered according to the list.html template, rather than the content files being rendered according to the terms.html file. I have already defined the taxonomy in config.toml. As I said, the issue is inconsistent and seems to flip-flop when I edit the content files or terms/list templates again.
Is there a way I can guarantee that the taxonomy will be rendered according to terms.html?
Hi there,
It’s difficult to say what’s going on without seeing your actual code. Do you have your code somewhere we can have a look at to try and replicate?
Sure, here’s my code for module/terms.html:
<div class="mw7 center mt4">
<div class="flex-ns flex-column mhn1-ns mb3">
{{ range sort .Pages "Params.order" "asc" }}
<div class="ph1-ns flex justify-stretch slide">
{{ .Render "li"}}
</div>
{{ end }}
</div>
</div>
and module/list.html:
<div class="mw7 center mt4">
<div class="f2 grey-3 mb2">{{ .Params.unitsTitle }}</div>
<div class="flex-ns mhn1-ns flex-wrap mb3">
{{ range sort .Pages "Params.order" "asc" }}
<div class="ph1-ns w-33-ns flex raise">
{{ .Render "unit-li"}}
</div>
{{ end }}
</div>
</div>
Within the content/ folder, I have the following structure:
And the config file:
[taxonomies]
module = "modules"
Each subcontent file (e.g. 01-your-name.md) has the appropriate “modules” parameter referring to it’s parent folder.
The goal is to display the _index.md files in the terms.html template when visiting /modules. However, some publishes result in the subcontent files (e.g. 01-your-name.md) being rendered here according to list.html. The appropriate use of list.html is to list the subcontent files with the metadata of the module index file (which always works properly).
So you have taxonomy definitions in the frontmatter of your terms?
Is /modules/
supposed to be content (as in regular pages) or taxonomy folder?
/modules/ itself is a content folder, yes. And yes each subcontent file, or unit, has it’s own taxonomy definition in the frontmatter.
I’m not sure that’s how taxonomies are intended to be used.
From: Taxonomies | Hugo
Taxonomies are classifications of logical relationships between content.
It looks like you are trying to have taxonomies defined inside its own terms?
Yeah that’s a good way of describing what I’m going for - is there an approach more suited to the structure I’m trying to achieve?
What are you trying to do?
If the relationships across pages are just hierarchical, you could get away with a “regular” content structure. The parent-child relationships can be inferred from the structure, and expressed using built-in page variables: https://gohugo.io/variables/page/
1 Like
I understand. I switched from using taxonomies to simply sections and I’m able to achieve the hierarchical structure I’m going for. Thank you for your guidance!