Special characters like dot and slash in title and using :title or :slug in permalink

I had this permalink set up for posts.

permalinks:
  post: "/post/:year/:month/:day/:slug"

The problem I notice was that characters like a dot or a forward slash in the posts title did not get replaced in the generated permalink for the post. I have solved it by using “:filename” but that is not optimal for me since I would like to include post number etc. in the filenames.

This example title

Lorem ipsum dolor sit amet/consectetur do example.org

generates the following permalink

/post/2006/02/02/lorem-ipsum-dolor-sit-amet/consectetur-do-example.org/

I had hoped it would become

/post/2006/02/02/lorem-ipsum-dolor-sit-amet-consectetur-do-example-org/

What is the best way to solve this? Is it a bug or expected behaviour?

You can set the slug in the pages with “problematic” front matter.

But it sounds like a bug, which you should register at GitHub.

Thanks, using slugs now. Will open an issue on GitHub

@frjo opened a ticket, for folks looking:

https://github.com/gohugoio/hugo/issues/3577

1 Like