# Disable/hide language selector for some pages or folders?

**URL:** <https://discourse.gohugo.io/t/disable-hide-language-selector-for-some-pages-or-folders/49810>\
**Category:** support\
**Tags:** i18n\
**Created:** [May 14, 2024, 12:28pm UTC](https://discourse.gohugo.io/t/disable-hide-language-selector-for-some-pages-or-folders/49810 "2024-05-14T12:28:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![huanlin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/huanlin/32/22018_2.png) [@huanlin](https://discourse.gohugo.io/u/huanlin)\
**Post date:** [May 14, 2024, 12:28pm UTC](https://discourse.gohugo.io/t/disable-hide-language-selector-for-some-pages-or-folders/49810/1 "2024-05-14T12:28:05Z")

</div>

Hi, my website contains multiple products’ documents in sub-folders, and some of them have both English and Chinese version, some have only English version.  
For those documents that have only English version, I’d like to hide/disable the language selector.  
I have no idea where to start. Would you shed some light?

If the above requirement is hard to implement, is there a way to “fall back” to default (English) version when a page doesn’t have Chinese version?

---

<div class="post-metadata">

**Author:** ![irkode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/irkode/32/26135_2.png) [@irkode](https://discourse.gohugo.io/u/irkode)\
**Post date:** [May 14, 2024, 12:33pm UTC](https://discourse.gohugo.io/t/disable-hide-language-selector-for-some-pages-or-folders/49810/2 "2024-05-14T12:33:15Z")

</div>

I would start with using `Page.isTranslated` in your language selector rendering code

> **[IsTranslated](https://gohugo.io/methods/page/istranslated/#prose)**
>
> Reports whether the given page has one or more translations.

---

<div class="post-metadata">

**Author:** ![huanlin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/huanlin/32/22018_2.png) [@huanlin](https://discourse.gohugo.io/u/huanlin)\
**Post date:** [May 14, 2024, 12:44pm UTC](https://discourse.gohugo.io/t/disable-hide-language-selector-for-some-pages-or-folders/49810/3 "2024-05-14T12:44:03Z")

</div>

Thank you @irkode , I’ll try to add some code with my language selector rendering code.

---

<div class="post-metadata">

**Author:** ![huanlin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/huanlin/32/22018_2.png) [@huanlin](https://discourse.gohugo.io/u/huanlin)\
**Post date:** [May 14, 2024, 2:36pm UTC](https://discourse.gohugo.io/t/disable-hide-language-selector-for-some-pages-or-folders/49810/4 "2024-05-14T14:36:16Z")

</div>

After reading [Docsy’s implementation of language selector,](https://github.com/google/docsy/blob/f4c7e2212843a0af159ec6e8ed49561a98ebdb05/layouts/partials/navbar-lang-selector.html) I still don’t know how to do it.

```auto
{{/* Link directly to documentation etc., if possible. */ -}}
{{ $langPage := cond (gt (len .Translations) 0) . .Site.Home -}}
<div class="dropdown">
  <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    {{- $langPage.Language.LanguageName -}}
  </a>
  <ul class="dropdown-menu">
    {{ range $langPage.Translations -}}
    <li><a class="dropdown-item" href="{{ .RelPermalink }}">{{ .Language.LanguageName }}</a></li>
    {{ end -}}
  </ul>
</div>

```

I think the first thing to do is the automatic “fall back” mechanism, because without falling back to the default English page, a user may navigate to a non-existing Chinese page by clicking links in current page.  
It woud be nice if Hugo provided this fall back feature. I have no idea how to implement it.

---

<div class="post-metadata">

**Author:** ![irkode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/irkode/32/26135_2.png) [@irkode](https://discourse.gohugo.io/u/irkode)\
**Post date:** [May 14, 2024, 7:40pm UTC](https://discourse.gohugo.io/t/disable-hide-language-selector-for-some-pages-or-folders/49810/5 "2024-05-14T19:40:41Z")

</div>

IMHO theres No OOTB here. remember, If there’s no translation, you have no page where you can get something like a link, title and all these can be localized.

you have

- Page.Language  
language of current page
- Page.AllTranslations  
which contains all translated Pages available for a current page (incl the current page)
- Page.Translations  
same as above but without current page
- site.Languages  
contains all languages that are defined.

so the difference of AllTranslations.Language and site.Languages are the ones not translated.  
the pages in Translations are the one where a translation exists.

There are some topics in the forum that handle that topic incl. code - try to search for that “missing translation fallback …”

hope that helps

---

<div class="post-metadata">

**Author:** ![huanlin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/huanlin/32/22018_2.png) [@huanlin](https://discourse.gohugo.io/u/huanlin)\
**Post date:** [May 15, 2024, 2:16pm UTC](https://discourse.gohugo.io/t/disable-hide-language-selector-for-some-pages-or-folders/49810/6 "2024-05-15T14:16:25Z")

</div>

@irkode , Thank you again for providing more information. Much appreciated!

---

<div class="post-metadata">

**Author:** ![irkode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/irkode/32/26135_2.png) [@irkode](https://discourse.gohugo.io/u/irkode)\
**Post date:** [May 15, 2024, 3:02pm UTC](https://discourse.gohugo.io/t/disable-hide-language-selector-for-some-pages-or-folders/49810/7 "2024-05-15T15:02:18Z")

</div>

Just felt over that one. Also a nic approach and definitely from guys that know hiw hugo works.

> [@Some pages should be in default language](https://discourse.gohugo.io/t/some-pages-should-be-in-default-language/48149):
>
> I am working on a site that has a few languages, and menus and pages have translations. However some pages should always be in the default language (en). This page [lang.Merge | Hugo](https://gohugo.io/functions/lang/merge/) explains something that may be a solution, but I’m not sure I understand it well enough. How do I show /content/defaultLanguage.md files no matter what localization is activated at the moment?

---

<div class="post-metadata">

**Author:** ![huanlin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/huanlin/32/22018_2.png) [@huanlin](https://discourse.gohugo.io/u/huanlin)\
**Post date:** [May 20, 2024, 3:22pm UTC](https://discourse.gohugo.io/t/disable-hide-language-selector-for-some-pages-or-folders/49810/8 "2024-05-20T15:22:57Z")

</div>

@irkode Thank you so much for more information.  
When I started this thread, I’ve also post my question on Docsy’s discussion board, and I got an answer from there. It seems working. At least I didn’t see a problem with that approach.  
For details, here is the link to that discussion:

> **[How to automatically fallback to the default language when a requested page...](https://github.com/google/docsy/discussions/1998)**
>
> Hi, my website contains multiple products' documents in sub-folders, and some of them have localized versions (e.g. Chinese), some don't. How to automatically fallback to the default language (Engl...

Thanks again!
