Skip to content
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

reuse content for multi language site using a all language #13196

Open
lucasew opened this issue Dec 26, 2024 · 2 comments
Open

reuse content for multi language site using a all language #13196

lucasew opened this issue Dec 26, 2024 · 2 comments
Labels
Milestone

Comments

@lucasew
Copy link

lucasew commented Dec 26, 2024

Today, to write content in a specific language you can do that without any suffix such as [slug].md, and that would assume the language specified in defaultContentLanguage, that's by default en. Considering this case, the all language would be a breaking change. Another way is by specifying the language such as [slug].pt.md, that would create a content for the pt language.

What I am suggesting here is a suffix that would create content for all languages specified in the config file. I'd suggest the suffix all.

For example, if you have the languages en and pt defined in the languages setting, post.md would generate for en, post.en.md would also generate for en, post.pt.md would generate for pt and post.all.md would generate for both en and pt using only one content file.

This could work by precedence, so, if no specific language content is defined then use the generic one. Plus, some frontmatter merging because stuff like cascade would be expected to work the same for all languages. I have an example where I need to customize the template for a section so I need to cascade the type down to a content subfolder and that way I need to copypaste the cascade to all markdown languages or it falls back to the default template.

@bep bep removed the NeedsTriage label Dec 26, 2024
@bep bep added this to the v0.141.0 milestone Dec 26, 2024
@bep
Copy link
Member

bep commented Dec 26, 2024

Today, to write content in a specific language you can do that without any suffix such as [slug].md, and that would assume the language specified in defaultContentLanguage, that's by default en.

For completeness, you can also assign languages via file mounts, so you can do:

[module]
  [[module.mounts]]
    source = 'content'
    target = 'content'
    lang = 'en'
  [[module.mounts]]
    source = 'content'
    target = 'content'
    lang = 'fr'

I do agree that it would be nice to somehow assign multiple languages (both tho mounts and single content files), but I'm not sure all is the best. For mounts we could certainly allow Glob patterns (e.g. {en,fr}), but I'm not sure how well that works in filenames.

lucasew added a commit to lucasew/lucasew.github.io that referenced this issue Dec 27, 2024
source: gohugoio/hugo#13196 (comment)

Signed-off-by: lucasew <lucas59356@gmail.com>
@lucasew
Copy link
Author

lucasew commented Dec 27, 2024

This is perfect. Just copypasted here and if I create a post without specifying a language it creates in all of them.

I only changed that fr to pt.

This simplified a lot the system. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants