New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support layouts per site/language #3360

Closed
bep opened this Issue Apr 18, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@bep
Member

bep commented Apr 18, 2017

See http://stackoverflow.com/questions/43149074/jekyll-or-hugo-theme-with-multilanguage-support

Hugo has already a good story for multiple languages, but it could fairly easily be made even more powerful by allowing template overrides per site/language.

Doing large portions of localisation via i18n files can be cumbersome, so to be able to create language-specific layout files/partials/shortcodes would be great.

A simple sample would be:

layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
├── _fr
│   ├── _default
│   │   └── list.html
│   └── index.html
└── index.html

In the imaginary site above we have a base template set that is used for all sites/languages, but then we override some of the templates for the French language (fr). This would also work for themes.

I have prefixed the language with "_" to avoid (hopefully) any section collisions.

@bep bep added the Enhancement label Apr 18, 2017

@bep bep added this to the v0.21 milestone Apr 19, 2017

@bep bep modified the milestones: v0.22, v0.21 May 9, 2017

@bep bep modified the milestones: v0.22, v0.23 Jun 7, 2017

@bep bep modified the milestones: v0.23, v0.24, v0.25 Jun 16, 2017

@ngsctt

This comment has been minimized.

Show comment
Hide comment
@ngsctt

ngsctt Jul 1, 2017

I've been wishing for exactly this as I've been reworking my site into Hugo. It'd be especially helpful for laying pages out according to different typographic conventions (I'm doing English/Japanese, and CVs are very different across the two).

I thought though, that the simpler way might be to use something like:

layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   ├── list.ja.html
│   └── single.html
│   └── single.ja.html
└── index.html
└── index.ja.html

Using filename.ja.html or filename-ja.html, etc. That way, the translations sit side-by-side with each other in the same folder, it matches the translated content system, and presumably you could just double the template search paths (eg. from https://gohugo.io/templates/content/#single-page), like so:

  • /layouts/TYPE/LAYOUT.LANG.html
  • /layouts/TYPE/LAYOUT.html
  • /layouts/SECTION/LAYOUT.LANG.html
  • /layouts/SECTION/LAYOUT.html
  • /layouts/TYPE/single.LANG.html
  • /layouts/TYPE/single.html
  • /layouts/SECTION/single.LANG.html
  • /layouts/SECTION/single.html
  • /layouts/_default/single.LANG.html
  • /layouts/_default/single.html
  • /themes/THEME/layouts/TYPE/LAYOUT.LANG.html
  • /themes/THEME/layouts/TYPE/LAYOUT.html
  • /themes/THEME/layouts/SECTION/LAYOUT.LANG.html
  • /themes/THEME/layouts/SECTION/LAYOUT.html
  • /themes/THEME/layouts/TYPE/single.LANG.html
  • /themes/THEME/layouts/TYPE/single.html
  • /themes/THEME/layouts/SECTION/single.LANG.html
  • /themes/THEME/layouts/SECTION/single.html
  • /themes/THEME/layouts/_default/single.LANG.html
  • /themes/THEME/layouts/_default/single.html

Additionally, this shouldn't really disrupt any pre-existing sites, and be relatively easy to add in I think.

ngsctt commented Jul 1, 2017

I've been wishing for exactly this as I've been reworking my site into Hugo. It'd be especially helpful for laying pages out according to different typographic conventions (I'm doing English/Japanese, and CVs are very different across the two).

I thought though, that the simpler way might be to use something like:

layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   ├── list.ja.html
│   └── single.html
│   └── single.ja.html
└── index.html
└── index.ja.html

Using filename.ja.html or filename-ja.html, etc. That way, the translations sit side-by-side with each other in the same folder, it matches the translated content system, and presumably you could just double the template search paths (eg. from https://gohugo.io/templates/content/#single-page), like so:

  • /layouts/TYPE/LAYOUT.LANG.html
  • /layouts/TYPE/LAYOUT.html
  • /layouts/SECTION/LAYOUT.LANG.html
  • /layouts/SECTION/LAYOUT.html
  • /layouts/TYPE/single.LANG.html
  • /layouts/TYPE/single.html
  • /layouts/SECTION/single.LANG.html
  • /layouts/SECTION/single.html
  • /layouts/_default/single.LANG.html
  • /layouts/_default/single.html
  • /themes/THEME/layouts/TYPE/LAYOUT.LANG.html
  • /themes/THEME/layouts/TYPE/LAYOUT.html
  • /themes/THEME/layouts/SECTION/LAYOUT.LANG.html
  • /themes/THEME/layouts/SECTION/LAYOUT.html
  • /themes/THEME/layouts/TYPE/single.LANG.html
  • /themes/THEME/layouts/TYPE/single.html
  • /themes/THEME/layouts/SECTION/single.LANG.html
  • /themes/THEME/layouts/SECTION/single.html
  • /themes/THEME/layouts/_default/single.LANG.html
  • /themes/THEME/layouts/_default/single.html

Additionally, this shouldn't really disrupt any pre-existing sites, and be relatively easy to add in I think.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jul 1, 2017

Member

@ngsctt I agree, that is much simpler than what I suggested.

Member

bep commented Jul 1, 2017

@ngsctt I agree, that is much simpler than what I suggested.

@bep bep self-assigned this Jul 1, 2017

bep added a commit to bep/hugo that referenced this issue Jul 2, 2017

output: Support templates per site/language
This applies to both regular templates and shortcodes. So, if the site language is French and the output format is AMP, this is the (start) of the lookup order for the home page:

1. index.fr.amp.html
2. index.amp.html
3. index.fr.html
4. index.html
5. ...

Fixes #3360

@bep bep closed this in #3670 Jul 4, 2017

bep added a commit that referenced this issue Jul 4, 2017

output: Support templates per site/language
This applies to both regular templates and shortcodes. So, if the site language is French and the output format is AMP, this is the (start) of the lookup order for the home page:

1. index.fr.amp.html
2. index.amp.html
3. index.fr.html
4. index.html
5. ...

Fixes #3360
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment