Temporarily Hide Japanese Pages in a Multilingual Hugo Site

ashley chow Br0SHmkJTY unsplash scaled
Genx Avatar

Goal

The objective is to keep a multilingual Hugo setup but temporarily prevent Hugo from building and exposing the Japanese variant, so only English is rendered and linked. This is best achieved by disabling the Japanese language via site configuration.

Prerequisites

A Hugo site already configured for multilingual use, with English and Japanese defined under the languages section, and English set as the default language via defaultContentLanguage = ‘en’. Hugo’s configuration supports a disableLanguages list and per‑language disabled flags, either of which will exclude a language from the build.

Quick solution (TOML)

Add or update the following keys in hugo.toml to disable Japanese. Either approach works; pick one and avoid mixing both for the same language.

  • Root-level switch (recommended for quick toggles):
disableLanguages = ['ja']
  • Per-language switch (alternative, equally valid):
[languages]
[languages.en]
disabled = false
weight = 1

[languages.ja]
disabled = true
weight = 2

Both methods remove Japanese from the build graph: Hugo will not render ja pages, will not generate ja URLs, and ja will not appear in .Sites, .Translations, or language switchers that iterate available translations.

Keep English as default

Ensure English remains the default so it cannot be disabled inadvertently. Hugo requires a default language and will not allow disabling it; set it explicitly if unsure.

defaultContentLanguage = 'en'

If defaultContentLanguageInSubdir = false (typical), the English site will render at / without /en/. If true, it will render at /en/. This setting does not affect language disabling, but it shapes final URLs.

Theme switchers and menus

Most themes render a language switcher by iterating .Translations or the .Site.Languages collection; when Japanese is disabled, these lists exclude ja, so the switcher naturally hides 日本語. If a theme hardcodes languages, adjust its partial to guard with .IsTranslated or iterate only existing translations, which becomes empty when ja is disabled. This pattern is widely recommended in multilingual setups.

Example guard (conceptual, in a language selector partial):

{{ if .IsTranslated }}
{{ range .Translations }}
<a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
{{ end }}
{{ end }}

Per-run toggle (no file edits)

For temporary builds, an environment variable can disable languages without touching files. On modern Hugo, space‑separated language keys are accepted; ensure your version handles multiple values correctly. For just Japanese:

HUGO_DISABLELANGUAGES="ja" hugo

Older versions had issues with multiple values, which were addressed around v0.115.4; confirm behavior with hugo config if you plan to pass several languages at once.

Verification steps

After applying the change, run a local build and confirm there is no ja output or navigation:

  • hugo or hugo server, then inspect the public/ folder or served site for /ja/ paths and language switchers.
  • hugo config | grep -i disableLanguages to verify effective settings during the session.

Re-enabling Japanese later

To bring Japanese back, remove ‘ja’ from disableLanguages or set [languages.ja].disabled = false, then rebuild. The prior content structure and translation links will be restored automatically, as long as file naming or translationKey settings are intact.

Complete example (final TOML)

A minimal multilingual config with Japanese temporarily hidden might look like this:

baseURL = 'https://example.com/'
title = 'My Hugo Site'
defaultContentLanguage = 'en'
defaultContentLanguageInSubdir = false
disableLanguages = ['ja']

[languages]
[languages.en]
languageCode = 'en-US'
languageName = 'English'
weight = 1

[languages.ja]
languageCode = 'ja-JP'
languageName = '日本語'
weight = 2

This retains the multilingual setup for later but excludes Japanese from the build until the disableLanguages list is cleared.

Share This Post:

Genx

in

Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

eighteen − two =

Webmention: Have you posted a response to this article? Let me know the URL: