hugo
hugo copied to clipboard
Add archetype per language
Working with #4535 I noticed an issue with archetypes with multiple languages with each its own content directory. I will improve that "what site/language does this content belong to" logic, but to make it non-ambiguous, I will also add a (optional) --lang
flag:
hugo new --lang=jp post/my-post.md
Doing that, it would also be good if each language could have its own set of archetype templates.
Since #4535 introduces a directory-based approach, we should probably prefix these to make them non-ambigous. My suggestion:
archetypes
├── _languages
│ └── jp
│ └── default.md
├── default.md
└── my-bundle
├── featured.png
└── index.md
/cc @RickCogley @kaushalmodi @regisphilibert @spf13 @anthonyfok and gang.
Note that I plan to wrap this up fairly quickly and include this in a "Revival of The Archetypes #2" release on Monday. There is also the new slice related template funcs that, with Go 1.11, I think we should get out there sooner rather than later. So Monday it is.
Do we need the lang flag? Can't the language be guessed by filename/location?
Do we need an archetype _language
directory? This prefixed directory introduces something rather unusual in Hugo. I wonder if we could do without. Couldn't we use the same file system as content files?
archetypes
├── default.md
└── default.jp.md
└── my-bundle
├── featured.png
├── index.md
└── index.jp.md
@regisphilibert I think you need to look at #4535 and #5233 and #5234 in full.
Do we need the lang flag? Can't the language be guessed by filename/location?
How would your examples look with a content directory per language? (which I think is a more common setup for sites that really need something like this).
OK, thinking a little about this, this isn't as obvious as I first thought. I think I will get #4535 working properly and see if I get some clarity from that.
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master
branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.
@bep are there any news regarding this issue along with https://github.com/gohugoio/hugo/issues/5234?
Do we need the lang flag? Can't the language be guessed by filename/location?
This makes sense, since, currently running next command doesn't guess filename location properly:
hugo new --kind post uk/2020/10/12/123.md
d:\Projects\hugoproject\content\en\uk\2020\10\12\123.md created
As I commented in #6895 (which is closed although problem persists), defaultContentLanguage
is not respected by hugo new
. This issue would solve that problem too? Thank you!
As I commented in #6895 (which is closed although problem persists),
defaultContentLanguage
is not respected byhugo new
. This issue would solve that problem too? Thank you!
it works by including the content dir in target path.
hugo new -k functions content/zh/new-function.md
content/zh/new-function.md created
quote from: https://discourse.gohugo.io/t/hugo-new-injects-language-code-into-path-multilingual-site/26416/2
it works by including the content dir in target path.
Thank you, @ikingye , I didn't know that. Tested here and it works indeed, turning my life a bit simpler! Although I think that is indeed a bug: if I specify defaultContentLanguage
, Hugo should follow that by default.
But thank you again!
It seems that this is related to a question on the forums: https://discourse.gohugo.io/t/multilingual-archetypes/39542/5
As Hugo is being used extensively in multilanguage sites, this seems to be something that could use prioritization.