How to disable hugo from inserting style attributes for RTL languages

I have a site with multiple languages. For RTL languages like Arabic, Hebrew, Farsi, etc. when I generate the site with hugo, all LTR languages are fine. However, RTL language versions of the site end up with dynamically inserted style attributes like this:

<ul style=";text-align:right;direction:rtl">

While this is in general annoying, I could live with it… if were not for the fact that the site also has a strict CSP which disables all inline styling, so the browser raises an error listing all the CSP violations in the console.

I could not find anywhere in the hugo source code where this could happen - I’ll admit I am not familiar with hugo’s source.

Any ideas?

Thanks in advance for any leads on how to disable.

Which theme are you using?

I am not using a theme - just built the site without a theme.

I am unable to reproduce the problem. Please share your repository. Thanks.

Sorry, I should have put together a hugo site demonstrating the issue to make it easier to recreate. I just did that and you can find it here: GitHub - caffeinejolt/hugo-rtl-problem: demonstrate style attribute injection for RTL languages

You can see in the public folder, that RTL languages such as these language codes: ‘ar’, ‘ur’, ‘fa’, ‘sd’, ‘ps’, ‘ug’, ‘he’ demonstrate the problem.

LTR languages have no style attribute injected into the final HTML.

I don’t understand.

This is in your source front-matter in oration parameter. So it is not generated by hugo, but put as is because already in your source.

So when you call {{ $.Param "oration" | safeHTML }} it is already in your param.

may be i miss something ?


oration: '<p style=";text-align:right;direction:rtl">أتمنى أيها الآباء المجندين أن أكون رحيمًا ؛ لا أريد أن أبدو متهاونًا وسط مثل هذا الخطر على الدولة. لكني الآن أتهم نفسي بالتقصير والخمول اللوم.</p><p style=";text-align:right;direction:rtl"> لكن مع ذلك ، هذا ، الذي كان يجب القيام به منذ فترة طويلة ، لدي سبب وجيه لعدم القيام بذلك حتى الآن ؛ سأقتلك ، إذن ، عندما لا يكون هناك شخص واحد يمكن العثور عليه شريرًا جدًا ، مهجورًا جدًا ، مثلك تمامًا ، بحيث لا تسمح بذلك بشكل صحيح.</p>'