Change title to URL conversion

Hi guys.

I’ve recently migrated my Wordpress blog to Hugo and I’m super happy with the decision so far but there is something that I would like to change.

Is there a way to change how Hugo automatically converts post/pages titles to URL? Or do I have to add an URL variable to each post/page in the front matter?

Wordpress converts forward slashs and full stops to hyphens, while Hugo keeps them. I prefer the way Wordpress translates titles to URL.

Example:

Title: New BYD battery 3.0 reaches 230 Wh/kg

Wordpress URL: date/new-byd-battery-3-0-reaches-230-wh-kg
Hugo URL: date/new-byd-battery-3.0-reaches-230-wh/kg

Isn’t using forward slash (“/”) and full stop (“.”) in URLs bad practice?

Also, Wordpress converts short words like “the” or “and” to hyphens as well, which makes sense to me as well.

So, is there a way to change how Hugo automatically converts titles to URLs? I couldn’t find it in the documentation.

Thanks!

Please post your site configuration.

Here it is:

The URL is technically correct, but what’s bothering me is this:

public/
├── new-byd-battery-3.0-reaches-230-wh/
│   └── kg/
│       └── index.html
└── index.html

The above is (sort of) unexpected, but has been that way since v0.54.0 (and maybe earlier). Again, technically we’re doing the right thing here.

Regarding the dot… you’ll need to override that with the slug field in front matter. The behavior not configurable.

1 Like

Thanks. I’ll use the slug field then.

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