How to translate only a subset of the pages?

My project has the following content structure:

└── content/
    ├── subpage/
    │   ├──
    │   └──

And these are my language settings in the .config.yml:

languageCode: "en-us"
defaultContentLanguage: "en"
    languageName: "English"
    weight: 1
    languageName: "Français"
    weight: 2

Now, when I check for {{ .IsTranslated }} in the template where the home page is rendered, it is set to true, even though a content/ file doesn’t exist.

Since a translation of the content/ has not been defined, why is Hugo creating an empty page for the French translation, in my particular case, the French home page?


Hugo Static Site Generator v0.48 darwin/amd64 BuildDate: 2018-08-29T06:33:08Z

EDIT: I found this (closed) issue, but the solution is not applicable since I already do it as the user mentioned in the solution.

EDIT 2: Here is a GitHub project to reproduce the issue:

I moved this to #support. Please read Requesting Help and share your code to get more folks helping you. :slight_smile:

@maiki thank you!
I read the help section and I managed to reproduce the problem in a very minimal Hugo setup:

1 Like

I have to admin, I am quite disappointed with the feedback here :disappointed:

It seems that your only option would be to use 301 redirects for the unwanted public/fr/index.html
Unless you choose to have the root /index.html translated as well.

Your issue is also relevant to the Override section url topic.

But you shouldn’t really feel disappointed, you got a definite reply.

Anyway there are many intricacies with Go and the way Hugo is built. There has been quite a bit of refactoring during the past year. What you’re asking may be a breaking change.

In any case, if the maintainer feels that current behavior will remain as is, there is not much left to be said, except for this:

If you know Go and you feel that this should change, then you could submit a PR to Hugo source (for review) along with proper tests (so that existing Hugo projects don’t break).

I dealt with this by checking the word count of the first translation before rendering the translation menu.

{{ if .IsTranslated }}

  {{ if gt (index .Translations 0).WordCount 0 }}
    <nav class="LangNav">
    {{ range .Translations }}
      <a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
    {{ end}}
  {{ end }}

{{ end }}