Hello,
When I put in the front matter two categories like:
categories:
category1 with spaces
category2
Hugo says my category template is “an incomplete or empty template”.
When I put only one category, like this:
categories:
It works.
bep
January 4, 2017, 9:18am
2
Abdarrahmaan:
Try
- "category1 with spaces"
Already tried, it’s the same. Also tried with toml.
I’m using tranquilpeak theme and hugo 1.8
Edit (sorry) : in JSON too it shows an error.
@Abdarrahmaan did you try the following?
categories: ["category1 with spaces", "category2"]
@Abdarrahmaan Can you point me to a repo? I wonder if you’re doing something wrong in the templating? For example, referencing a single value rather than a range.
Repo of the theme:
The template mentionned in the error message is:
{{ $ancestors := first .level (split .category.path " ") }}
{{ if eq ($ancestors | len) ((intersect $ancestors (split .parent " ")) | len) }}
<div id="posts-list-{{ .category.name | urlize }}" class="archive" data-category="{{ .category.name }}" data-parent-categories="{{ delimit $ancestors "," }}" style="display: block;">
<h4 class="archive-title text-xlarge">
<a class="link-unstyled" href="{{ .category.name | urlize }}">{{ .category.name }} ({{ .scratch.GetSortedMapValues (replace .category.path " " "/") | len }})</a>
</h4>
<ul class="archive-posts">
{{ range (.scratch.GetSortedMapValues (replace .category.path " " "/")) }}
<li class="archive-post" style="display: list-item;">
<a class="archive-post-title" href="{{ .RelPermalink }}">{{ .Title }}</a><span class="archive-post-date"> - {{ partial "internal/date" . }}</span>
</li>
{{ end }}
</ul>
{{ $index := (add .level 1) }}
{{ $path := (printf "%s" .category.path) }}
{{ range .scratch.GetSortedMapValues (printf "category-level-%d" $index) }}
{{ partial "internal/recursive-categories-full-2.html" (dict "scratch" $.scratch "category" . "level" $index "parent" $path) }}
{{ end }}
</div>
{{ end }}
The cause was this :
(replace .category.path " " “/”))