How to redirect root to /es/?

Initially I decided to keep the English language as main content of the website but started writing everything in Spanish.

My Spanish content is under /es/.
The root (without /en/) stays reserved for English in the future.

However, since I don’t have any English content, I ended up with empty root page. For that reason, in the meanwile I would like to redirect all / to /es/.

Can I do so from Hugo config only or this will require me messing with server requests? And if that involves changes on the server, what redirection rule will look like (I use Cloudflare).

I would prefer to redirect / to /es/ instead of redirecting /es/ to / as pages are already indexed by search engines.

You need to setup the redirect on Cloudflare: https://developers.cloudflare.com/pages/platform/redirects

Hm… I forgot the following configuration setting:

defaultContentLanguageInSubdir: true

Basically with the above Hugo will redirect the root to /es/ with the meta refresh tag on the front-end.

@alexandros setting the defaultContentLanguageInSubdir to true indeed makes the redirect, this is a bad solution SEO wise as the Hugo will introduce <meta name='robots' content='noindex'> tag to the index of root page.

I am afraid that you can only do a proper redirect on a server. As I mentioned above you need to do it on Cloudflare.

Hugo is only a static site generator.

We do not offer guidance on server redirects in this forum.