Question mark (?) as a tag --- taxonomy slugs


#1

I’m converting an old Wordpress to Hugo. It’s about 1000 posts and 4000 comments, dating back to 2004. I’m making an effort to preserve all urls, etc., to provide continuity to the past.

I have two posts that have the tag ‘?’, or just a question mark character. Hugo does not like this. I realize this is a bad choice for a tag. If I don’t quote the ? in the post metadata (using YAML), I get the following error:

ERROR 2019/02/10 11:37:35 GetParam("tags"): Unknown type []interface {}

If I do quote the question mark in the YAML metadata, the tag looks fine on the post page as question mark, but the link to the tag page is not functional (ex. “site.com/tags/” instead of “site.com/tags/?/”).

Wordpress deals with this by displaying the tag as a question mark but linking to a tag id number/slug (ex. “site.com/tags/308/”).

I think what I am looking for is setting a slug for a taxonomy. Is there anyway to do that? Alternately, is there some appropriate way I can encode a question mark character as a tag/taxonomy which Hugo will do the right thing and display it in my HTML and generate functioning links?


#2

I was thinking you could set it in front matter for the term _index.md, but I’m not even going to test it, because I’m not going to generate /content/tags/?/_index.md or whatever… it’s a bad tag, which is supposed to be useful for your human audience, and you lucked out you only have to replace it twice. :slight_smile:


#3

Agreed, it is a bad tag. So you are saying I could make an _index.md (where?) and replace the slug for the tag in the front matter to something else like “question-mark”?


#4

No, I’m saying abandon this query. Your solution is to replace that term.

Currently in Hugo when you want front matter to change you add it to the file that loads for a given piece of content. Where would you add it for ?? A file called ?/_index.md? No, you’d keep it in something like question-mark/_index.md. There is this very real question of what do you name the file where you set the slug. At that point, I just make a better tag.

If you want the title to be ?, and the tags link to be a single ? for folks with pointing devices to try to press, then set the title to ? in the front matter for the term, but you’ll need to make up that new term, and change the tag in the pieces of content that reference it. And for completion sake, though no one has ever clicked on that tag, you might redirect /tags/308 to /tags/question-mark.