Partial is said to be incomplete, but it's unclear to me why

When I run hugo it complains about my layouts/partials/tags.html file being an incomplete template. I don’t understand why.

Here is the error being generated:

$ hugo
Started building sites ...
ERROR: 2017/01/11 16:47:42 general.go:236: partials/tags.html is an incomplete or empty template
Built site for language en:
0 draft content
0 future content
0 expired content
51 regular pages created
19 other pages created
0 non-page files copied
32 paginator pages created
11 tags created
0 categories created
total in 259 ms

Here is the template in question, located at layouts/partials/tags.html:

<div class="tags">
Tags: {{ range sort .Params.tags }}<a href="/tags/{{ urlize . }}" >{{ lower . }}</a> {{ end }}

I’ve tried modifying it to be something simple based on the examples on the functions page, eg:

<div class="tags">
Tags: {{ range sort .Params.tags }} {{ . }} {{ end }}

This still fails complains. For some reason, however, it does build and I see the tags, though they’re not sorted. Any pointers as to why?

On phone so can’t test but maybe {{ . | lower }} instead.

Thanks for the thought, but that doesn’t seem to fix it.

Did you try the pipes on both? Do you have any files that are missing tags in the front matter that you’re trying to range over? (Although this would throw a different error, I believe.) Can you point me to the repo with the full example?

The repo is private at the moment (for no real reason), so it’s tricky to link you atm. If it remains an issue I will add you.

I made sure tags are in the frontmatter of every post and that did indeed fix it. Is there a way to first check for the presence of tags to appease the template engine, or is it just assumed that every post will have at least one tag?

Yep, a couple ways, but I prefer the terser with over isset:

{{with .Params.tags}}
<div class="tags">
  {{range sort . }}
  <a href="{{.Site.BaseURL}}tags/{{ . | urlize}}">{{ . | lower}}</a>

Be sure to check the docs on with, isset, etc for more information.

That is almost working for me. Making the change you suggest but removing {{.Site.BaseURL}} allows the hugo command to complete without an error. Keeping {{.Site.BaseURL}} complains with another incomplete template error.

It looks like this one is related to {{.Site.BaseURL}}, as removing it allows the build to complete silently. Moving {{.Site.BaseURL}} outside of the with outputs the baseurl from my config.toml, so I don’t think it’s just a matter of it not bieng set. Perhaps the . is referring to the tag inside of the range command, or something like that?

Either way, your fix does the trick. I’d prefer to be able to include the baseurl just in case I move it, and because it’d help me better understand the templates, which I always struggle with.