Slash in tag name

Hello,
Among my taxonomies I have this tag: “Guide on GNU/Linux”. The only tag with a slash in its name.

The problem is that Hugo — for this tag — creates this directory structure:

/tags/guide-on-gnu/linux/

which is not what I want. It should be:

/tags/guide-on-gnu-linux/

I temporarily changed the name of the tag in “Guide on GNU-Linux” but this name isn’t correct.

I’d like to have:

  • tag name = “Guide on GNU/Linux”
  • url = /tags/guide-on-gnu-linux

What can I do to have this?

Thanks,
Aldo

Don’t use a slash in term names unless you want a hierarchical term structure.

tags = ['guide-on-gnu-linux']

To change the way the term is displayed:

hugo new tags/guide-on-gnu-linux/_index.md

content/tags/guide-on-gnu-linux/_index.md

+++
title = 'Guide on GNU/Linux'
date = 2022-05-05T10:28:23-07:00
draft = false
+++

To display the tags on a content page, use the .GetTerms method:

{{ with .GetTerms "tags" }}
  {{ range . }}
    <a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
  {{ end }}
{{ end }}
2 Likes

Thanks @jmooring for the reply.

The “problem” is that the name “GNU/Linux” has a slash inside.

I created the page tags/guide-on-gnu-linux/_index.md and changed draft to false in the front matter of that file. Then, using sed in the terminal, I changed the tags of the various posts from “Guide on GNU-Linux” to “Guide on GNU/Linux”.

The result is that now, in the taxonomy list page (/tags/) I have two entries:

  • “Guide on GNU/Linux” that points to /tags/guide-on-gnu-linux/ but the page is empty (there is only the title of the page);
  • “Guide on GNU/Linux” that points to /tags/guide-on-gnu/linux/, with all posts under that tag.

What can I do?

No. That is not what I recommended. See my previous comment, and this example:

git clone --single-branch -b hugo-forum-topic-38465 https://github.com/jmooring/hugo-testing hugo-forum-topic-38465
cd hugo-forum-topic-38465
hugo server
1 Like

Ok, solved! Now all is perfect.

I have only to remember to write this in the front matter of new posts, when needed:

tags = ['guide-on-gnu-linux']

Thanks for your patience! :slight_smile:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.