Json output format - no fallback for default language - potential bug?

Hello,

When using following configuration (config.yaml) for custom (json) output and site languages:

outputs:
  home:
  - HTML
  - JSON
languages:
  en:
    languageName: EN
    weight: 1
  x1:
    languageName: X1_LANG
    weight: 2
  x2:
    languageName: X2_LANG
    weight: 3

accessing the addres http://localhost:1313/en/index.json returns “404 page not found” error, instead of making a fallback to http://localhost:1313/index.json which works (the way it works for standard html pages). All other languages work (localhost:1313/xx/index.json).

json output is defined in _default/list.json template.

I tried also a dedicated content/folder/_index.md file with frontmatter outputs definition as above, but that was even worse - only the default ‘en’ language was available.

Although I am able to workaround the first case - both seem bug candidates for me. Or…? :slight_smile:

Thanks,
t.

If you want to serve the default content language from a subdirectory:

defaultContentLanguageInSubdir = true

https://gohugo.io/getting-started/configuration/#defaultcontentlanguageinsubdir

Thanks for quick reply, but I am expecting the other way round - redirect from ‘/en/’ to root ‘/’, so the

defaultContentLanguageInSubdir = false

is what I need to keep.

Then you need to handle that server-side with a 301 redirect.

Hugo redirects /en/index.html to /index.html using a meta element with an http-equiv="refresh" attribute. That cannot be done within a JSON file.

Ah - now it’s clear. Thanks a lot.
:+1:

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