Hugo Tip for Greek language users: Uppercase without accents

The main problem I have encountered with CSS in Greek language websites is that if one uses text-transform:uppercase; the uppercase letters are displayed with accents that are only used in lowercase. For example Η Συλλογή becomes Η ΣΥΛΛΟΓΉ instead of the grammatically correct Η ΣΥΛΛΟΓΗ.

Previously I was removing these accents with jQuery on the frontend, but thanks to this topic Easier way to replace array with array? - support - HUGO I was able to have the accents removed directly in Hugo.

For example

<h3>{{ $pairs := (dict "ά" "α" "έ" "ε" "ή" "η" "ί" "ι" "ό" "ο" "ώ" "ω" "Ά" "Α" "Έ" "Ε" "Ή" "Η" "Ί" "Ι" "Ό" "Ο" "Ώ" "Ω") }}{{ $.Scratch.Set "specialTitle" .Title }}{{ range $key, $val := $pairs }}{{ $.Scratch.Set "specialTitle" (replace ($.Scratch.Get "specialTitle") $key $val) }}{{ end }}{{ $.Scratch.Get "specialTitle" }}</h3>

Of course this function can be easily expanded to include other Greek language diacritics such as diaeresis Ϊϊ Ϋϋ and acute diaeresis ΐ ΰ

My thanks to @JLKM who originally posted this solution (even if it was for another language).

2 Likes

for Romanian language, the $pairs variable should be

{{ $pairs := (dict "ă" "a" "â" "a" "î" "i" "ș" "s" "ț" "t" "Ă" "A" "Â" "A" "Î" "I" "Ș" "S" "Ț" "T") }}
1 Like