Hyphenating paragraphs

I would like to be able to apply hyphenation to my blog text. This is similar to How to use hyphenator.js with Hugo? (https://discuss.gohugo.io/t/how-to-use-hyphenator-js-with-hugo/4319) but that is using a JS library where I’d rather hyphenate during generation.

I’ve found a go library for hyphenation and I would like to try and use it in hugo. However, my experience with Golang and Hugo is very limited. Therefore, any recommendation on how to integrate this best into Hugo would be appreciated.

My first idea is to use functions from template and define a custom function hyphenate that I would use on {{ .Content }} in the template. Would this work? Is there a better way? How should I add the custom function to hugo?

Any help would be greatly appreciated.

Hyphenating during generation sounds nice (I dislike having Javascript on my pages, too), but have you checked to make sure that all those soft hyphens in your HTML output won’t break searchability?

That is a good point! Honestly, I hadn’t thought about that. Hard hyphen have little effect because tries out different spellings of words anyways… but adding a lot of soft hyphens or ­ might still effect/confuse the search engine.

Also if you hyphenate during generation, you will end up with hyphens in the middle of a line on smaller screens.

That would only happen if a hard hyphen - is included. With soft hyphens this doesn’t happen.

With regards to SEO, I could only find a single page discussing this. I couldn’t understand why it would affect search engines as they are quite smart.

Does anyone have an idea how to implement this in the latest versions of Hugo?