Hugo

Front matter URL: two dashes get parsed into one -

Hi,

I discovered the following problem:
In my front matter I define a URL, let’s say:

url: my--test

What I would expect from to be the output of this would be a file called “my–test.html”.
Surprisingly the output is: "my**-**test.html.
Two dashes get turned into one, which is not what I would expect and need.
How I can prevent this from happening?

I run Hugo at version:
Hugo Static Site Generator v0.54.0/extended windows/amd64
and configured it to use

canonifyURLs: true

Thanks for your help and best wishes,
Max

1 Like

This looks like a bug. I can reproduce with 0.55.5

Strangely enough this happens with double dashes -- but not with double underscores __

Please open a GitHub issue over here: http://github.com/gohugoio/hugo/issues/

1 Like

Thanks for the reply.

I opend a new issue: https://github.com/gohugoio/hugo/issues/6007

1 Like

Any news on this issue?

I tried to work around this by naming the content file my--test.md and then setting config file permalinks to /:filename/ but it still reduces it to one dash.

This is how Hugo normalizes file paths and it has been like this since Hugo 0.05 or something, i.e. always. @spf13 may tell us why, but I like how it behaves and I believe this is the first time I have seen someone raise this as an issue.

We cannot change the default behaviour. We may add a config option or something, but for me to consider that there have to be more than a handful people wanting it.

1 Like

Hi @bep,

thanks for your reply.
For me it is strange that we only encounter this “problem” now, when try building our content with Hugo 0.5x.x, especially when you say, that the normalization behaviour hasn’t changed since 0.05.
We are currently running a project using https://github.com/gohugoio/hugo/releases/download/v0.37.1/hugo_0.37.1_Linux-64bit.tar.gz
and with this version we can create pages with two dashes in the url.
I can even give you a real world example where it is working for us with version 0.37.1 but not with 0.5x.x: we have content where in the frontmatter we define:
url: zeeland/nieuw--en-sint-joosland/
name: 'Nieuw- en Sint Joosland' (we get two dashes in the url because we escape whitespaces with dashes)
When we render that page the resulting output is (as we expect): https://www.autoscout24.nl/auto/tweedehands-auto/zeeland/nieuw--en-sint-joosland/ (as you can see two dashes).
So for us it would be great if we could somehow configure Hugo to keep the two dashes.

Thanks for your time and effort,
Max

I take all of this from memory, which isn’t always perfect. But I notice there is a GitHub issue to remind us about it. I vaguely remember we changed the “dash behaviour” at some point, probably to avoid many repeating dashes.