Taxonomy terms .Permalink - spaces vs. dashes

The following code:

{{- with (.GetTerms "tags") -}}
  <div class="d-flex flex-row gap-2">
    <div class="icon">
      {{- partials.Include "icon.html" "tags" }}
    </div>
    <div class="d-flex flex-row gap-2">
      <span>{{ lang.Translate "theme.tags" }}: </span>
      {{- range . -}}
        <a rel="tag" href="{{- .Permalink -}}"
          >#{{- .Title | urlize | lower -}}</a
        >
      {{- end -}}
    </div>
  </div>
{{- end -}}

leads to links in the {{- .Permalink -}} part that come as me%20now. The tag term is actually me now (space). Hugo creates the page as me-now.

This started with recent Hugo versions. Is there a way to correctly call the permalink or do I have to “hack” somehow a space to dash conversion for the link?

Before the display was with space and Hugo linked and created dashed.

I wonder where I went wrong in that Hugo is creating the page with dashes, but then in the .Permalink uses spaces.

Sample:

config/_default/taxonomies.toml:

tag = "tags"

You are currently seeing this:

Posts tagged with #Me-Now

What do you want to see?

I cannot reproduce this.

That “Posts tagged with #Me-Now” is the second level of issues. Before it showed “#me-now” (I don’t have proof of that, but it would have taken my interest somehow if it happened that way). I fixed the initial issue above (dashes vs. spaces) with renaming all my tags so they don’t have spaces. I think that is the easiest way to fix my issue.

Before I saw “#me-now” as title of these tags.

There are plenty of other tags with spaces in my blog, but I refactored them all into having dashes and GoHugo is happily doing “the right thing” now.

not anymore probably because I fixed it on the live website. Maybe at this commit it will show.

Capitalization

Hugo has always capitalized the title of section and taxonomy pages that are not backed by a file. With the introduction of v0.123.0, Hugo also capitalizes the title of term pages that are not backed by a file. With v0.123.3 and later you can (finally) disable auto-capitalization:

capitalizeListTitles = false # default is true
pluralizeListTitles = false  # default is true

If we were starting over both would default to false. The current defaults are backward compatible, but don’t make much sense.

Spaces vs. hyphens

Regardless of version, the assigned terms “a b” and “a-b” are equivalent with respect to the internal identifier and the relative permalink.

v0.122.0…

assigned
term
internal
identifier
title relpermalink[1]
a b a-b a-b /tags/a-b/index.html
a-b a-b a-b /tags/a-b/index.html

v0.123.0 and later…

assigned
term
internal
identifier
title[2] relpermalink[1:1]
a b a-b A-B /tags/a-b/index.html
a-b a-b A-B /tags/a-b/index.html

EDIT: There seems to be some indeterminacy when PAGE-A has tag “a b” and PAGE-B has tag “a-b”. We’re not detecting a page collision when building with --printPathWarnings. See #12202


  1. Assumes you have not set permalinks in your site configuration ↩︎ ↩︎

  2. Assumes that capitalizeListTitles is not set to false ↩︎