# How to redirect root to /es/?

**URL:** <https://discourse.gohugo.io/t/how-to-redirect-root-to-es/36392>\
**Category:** support\
**Created:** [January 6, 2022, 9:18am UTC](https://discourse.gohugo.io/t/how-to-redirect-root-to-es/36392 "2022-01-06T09:18:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![justshipit](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@justshipit](https://discourse.gohugo.io/u/justshipit)\
**Post date:** [January 6, 2022, 9:18am UTC](https://discourse.gohugo.io/t/how-to-redirect-root-to-es/36392/1 "2022-01-06T09:18:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 6, 2022, 9:36am UTC](https://discourse.gohugo.io/t/how-to-redirect-root-to-es/36392/2 "2022-01-06T09:36:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 6, 2022, 5:01pm UTC](https://discourse.gohugo.io/t/how-to-redirect-root-to-es/36392/3 "2022-01-06T17:01:43Z")

</div>

Hm… I forgot the following configuration setting:

```auto
defaultContentLanguageInSubdir: true

```

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

---

<div class="post-metadata">

**Author:** ![justshipit](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@justshipit](https://discourse.gohugo.io/u/justshipit)\
**Post date:** [February 2, 2022, 9:06am UTC](https://discourse.gohugo.io/t/how-to-redirect-root-to-es/36392/4 "2022-02-02T09:06:44Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [February 2, 2022, 9:08am UTC](https://discourse.gohugo.io/t/how-to-redirect-root-to-es/36392/5 "2022-02-02T09:08:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [February 2, 2022, 9:08am UTC](https://discourse.gohugo.io/t/how-to-redirect-root-to-es/36392/6 "2022-02-02T09:08:35Z")

</div>


