Hello!
We are encountering difficulties with this subject: until now, we have been managing our redirects with absolute aliases. We have monolingual and multilingual sites based on the same Hugo theme. Do you have any recommendations for managing the following cases in a consistent manner?
-
A monolingual redirect to multilingual: “/us/” to “/fr/a-propros/”
-
A multilingual redirect to multilingual: “/en/us/” to “/en/about/”
-
Redirecting from one language to another: “/en/us/” to “/fr/a-propos”
The latter case is very rare, but it can happen if the old site was very poorly organized!
We are developing the Osuny CMS, a digital commun developed in rails managing several hundred sites based on the same theme based on Hugo.
Furthermore, the websites are not on servers running Apache, so we cannot rely on a solution with htaccess, for example…
Thank you very much for your help!
What are they running on?
If you are sure you need to create client-side redirects…
git clone --single-branch -b hugo-forum-topic-56758 https://github.com/jmooring/hugo-testing hugo-forum-topic-56758
cd hugo-forum-topic-56758
rm -rf public/ && hugo server
Files of interest:
layouts/home.html (lines 16-18)
layouts/_partials/generate-client-side-redirect-files.html
data/redirects_from_root.yaml
The data file should only contain source/destination pairs where the source URL is server-relative (e.g., redirecting from https://example.org/foo/ to https://example.org/en/examples/a/). Or you can define all of the redirects in the data file, and stop using the aliases front matter field.
1 Like
Most of the websites created with Osuny are hosted with Deuxfleurs, who uses Garage, a S3-like hosting service: https://garagehq.deuxfleurs.fr/
Thanks for the tip, we’re going to try this on our side! We’ll get back to you!
1 Like