How to use a single language in a multilingual theme?

I have been using the theme at GitHub - razonyang/hugo-theme-bootstrap: An extreme fast, responsive and feature-rich Hugo theme. 一个极快、响应式和功能丰富的 Hugo 主题。 on a test website and starting to add content. It is a multilingual theme, yet I only want English on the site.

Part of the top navbar has the language selection. It would obviously be less work to simply remove that feature. There are plenty of docs on how to make a theme multilingual, but not much on how to use a multilingual theme for a single language.

Part of the config.toml

# Multilingual mode
defaultContentLanguage = "en"
defaultContentLanguageInSubdir = true

This is the code in the file translations.html

{{ if and .IsTranslated }}
<div class="post-translations nav-item dropdown me-2 d-inline-flex">
  <a class="nav-link p-0" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
    <i class="fas fa-fw fa-language me-1"></i>{{ $.Language.LanguageName }}
  </a>
  <div class="dropdown-menu">
    {{- range .Translations -}}
    <a class="dropdown-item post-translation" href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
    {{- end -}}
  </div>
</div>
{{ end }}

But I can’t see at present how to set “IsTranslated” on or off ?

Later … Just saw the following from Multilingual Mode | Hugo on how to disable a language

disableLanguages = ["fr", "ja"]

This seems to have worked, however not too sure about how the directory structure in /exampleSite is based ?

# Multilingual mode
#defaultContentLanguage = "en"
#defaultContentLanguageInSubdir = true
disableLanguages = ["zh-cn", "zh-tw"]

Meaning that with only one language, there is still…/content/en ? But at least the language selection in the navbar has gone. The build has only done the single language, whereas previously there were 3 languages built …

Start building sites … 
hugo v0.84.3-A1B0353C linux/amd64 BuildDate=2021-06-29T11:40:22Z VendorInfo=gohugoio

                   | EN  
-------------------+-----
  Pages            | 80  
  Paginator pages  | 10  
  Non-page files   |  0  
  Static files     | 90  
  Processed images |  0  
  Aliases          | 34  
  Sitemaps         |  1  
  Cleaned          |  0

Have you copied all the configs from the exampleSite?

In that case you have languages configured in the hugo-theme-bootstrap/languages.toml at master · razonyang/hugo-theme-bootstrap · GitHub file.

Just clear that file out and you have no languages configured.

With only a single language you do not want defaultContentLanguageInSubdir so remove it or set to false.

1 Like

Because of the method the config files were structured (it seemed non-standard to me), to install the theme after the git was

# Copy configuration
mkdir config
cp -a themes/hugo-theme-bootstrap/exampleSite/config/* ./config

# Rename the single config file
mv config.toml config.toml.orig

That was because the config.toml that was installed by hugo kept conflicting and URI’s weren’t resolving properly.

Yes, there were two options, one with all the config values in config.toml, or a seperate file for each different type of config set. Then there was /config/_default and /config/production , a structure to delineate between local testing and live/deployed/production site. In hindsight the theme probably wasn’t the best choice for me, as a newcomer to hugo.

Okay thanks. I’ve done that, and now there is not even an /en path, which is the desired result when just a single language. Also of course no other language paths/files. That all works fine on a test website. One thing different was it went and created these paths …

/public/about-hugo/
/public/about-us/
/public/contact/
/public/page/1 (no index.html though)
/public/page/2
/public/page/3
/public/page/4

No doubt even if those extras paths are there, yet not in the navigation, then it doesn’t matter.

Okay, so your tips worked fine, and it seems I do not need the disableLanguages setting in the /mysite/config/_default/config.toml . These are the current settings.

# Multilingual mode
#defaultContentLanguage = "en"
#defaultContentLanguageInSubdir = true
disableLanguages = ["zh-cn", "zh-tw"]

Thanks for your help, much appreciated. In hindsight, it would have been better if I had started learning hugo with a single language theme for starters. However I liked the look /feel of this theme and the navigation was almost what I needed, so not much to change. When I was testing different themes, many seemed to have Netlify or other ( Hosting & Deployment | Hugo ) requirements, and I don’t use that. However I have just noticed Deployment with Rsync | Hugo , and may test using Beyond Compare ( https://scootersoftware.com/ ) which has a sync feature.

If you want to really understand how Hugo and Hugo themes work I recommend you start from scratch and build your own theme.

Even if you do not plan to use that theme it will give you a understanding that will help you when you make use of other themes.

1 Like

@frjo Thanks, yes good idea.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.