Hugo: Support making language content with `hugo new` in directory format

Created on 25 Sep 2020  路  2Comments  路  Source: gohugoio/hugo

So far, we can only create language content with hugo new in file format (hello-world.en.md). But making language content in dir format (content/en/post/hello-world.md) has it own advantange, and yet there is no support from hugo new for it. I think it's time for us to support this feature. My short-term proposal would be like this:

# long flag
hugo new post/hello-world.md --language-code en

# short flag
hugo new post/hello-world.md -c en # the `c` can be understood as content or code in language-code

In a long-term, my proposal would be a bit interactive CLI. So what do you think?

A discussion from forum could be found here

Proposal

Most helpful comment

At the moment, we do not have a default language failover if there is a missing translation lang/page.md.

But sometimes we do not want an empty lang/page.md.

So the solution is to be sure to have all language pages and for example copy en/page.md to lang/page.md. So we have a page in this language, even if it is written in english.

A good addendum would be to have an option to create the page in all declared languages.
Something ala --language-code all.

[EDIT] And with @davidcoallier proposal for config options, we could have the "date config" in each language for example in those options.

All 2 comments

Don't forget page bundles. I have a deep sitting issue that I grudgingly accept at the moment, a new leaf bundle has to be created via explicit hugo new post/hello-world/index.md call.

Maybe this can be combined into a rework of how hugo new post works in general.

Idea (without knowledge of how hugo internals work):

  • add configuration variables that define

    • if a new post should create a post in all defined languages

    • if a new post should be created as leaf bundle or markdown file

Then running hugo new post/something will create a new post according to the configuration above.

At the moment, we do not have a default language failover if there is a missing translation lang/page.md.

But sometimes we do not want an empty lang/page.md.

So the solution is to be sure to have all language pages and for example copy en/page.md to lang/page.md. So we have a page in this language, even if it is written in english.

A good addendum would be to have an option to create the page in all declared languages.
Something ala --language-code all.

[EDIT] And with @davidcoallier proposal for config options, we could have the "date config" in each language for example in those options.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

artelse picture artelse  路  3Comments

VoidingWarranties picture VoidingWarranties  路  3Comments

kaushalmodi picture kaushalmodi  路  3Comments

antifuchs picture antifuchs  路  3Comments

ianbrandt picture ianbrandt  路  3Comments