-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
i18n: multiple_files structure for file collections #5280
Comments
Hi @jf-home, the lack of support for file collections was part of scoping down the feature so we can launch it quickly and get more feedback. The challenge for file collections is that you configure a specific file path for the entry. We'll need to think of how the configuration for that looks like when using Do you configure a folder? Not sure. I suggest outlining a proposal on how you think this should look like from a configuration standpoint, based on our feature template. |
Hi @erezrokah, I appreciate your prompt response and have outlined my thoughts as requested below... Requirement Possible solution
What would be particularly useful is to have the ability to specifiy a different file name for each locale, as the file name is often used to influence the slug. This would provide a better end user experience through the Gatsby site and also improve SEO for each locale. Example configuration (using kebabcase where necessary):
Possible alternatives
The drawback with this approach is that it doesn't allow for a different file name (and therefore slug) across locales, so it wouldn't be as effective from an SEO and user experience perspective. |
In my opinion changing As you have already noted, it would mean that you need a different way to generate your slugs, but with collections it's the same. Sadly I've no knowledge of Gatsby. Maybe there's a different way to generate slugs? What do you think @jf-home ? |
Hi @apriljunge, You make a good point about limiting the potential for confusion and improving maintainability. Unfortunately, my use and understanding of Gatsby leads me to believe that the slug is generated by the markdown file name, so the suggestion of having a single file name with inferred localization would be limiting from an SEO perspective. That said, there may be others with more experience of Gatsby that can confirm or, alternatively, offer another suggestion @KyleAMathews? I do like your suggestion of inferred localization though. It's nice and simple and may well suffice for those not so concerned with SEO. Thanks for joining the conversation - much appreciated! |
I'm loving this discussion ❤️ Personally I prefer if the CMS infer the slug to have the most minimal approach as the first iteration. If we allow As for the string template I think it might be better to handle slug customization via a more general approach as a part of #445. To emphasise, the CMS will only infer the base name part of the file path. I think there is still some confusion with having |
Valid point. I also thought about |
I don't think we need to take
This would seem to be the simplest solution initially which @erezrokah rightly suggests is an important consideration. As for slug customization - I can see an arguement for this both ways. If you provide the ability for content editors to specify the alternate slug, hopefully they'll be meaningful and well-formed. However, if you make it an "admin" feature (i.e. customizable through the config.yml file), there is more potential for visibility, process and control around changes. The control aspect shouldn't be overlooked imo as when a slug changes, a redirect really should be set up to ensure the old slug doesn't result in a 404. This may not be too important for small ad hoc sites, but for enterprise users, I can see it being quite important. As for your last comment @erezrokah - I believe this really comes down to how well the feature is documented. As mentioned above, I don't think the file name should be taken literally in the case of i18n file collections. If this is communicated clearly then it shouldn't present a problem (imo). @apriljunge - I'd be interested in your thoughts. |
Found this thread while running into the same problem using Hugo, which also doesn't like to parse i18n content from single files. Like Gatsby, Hugo prefers multiple files My work-around at the moment is to organize the content for each single page as a folder collection, resulting in longer links like I imagine that enabling an i18n multiple_files structure for file collections would enable the links to appear like I agree with @jf-home's suggestion of the language codes being inferred. It appears to already work like that for folder collections, so the pattern would be consistent. Happy to contribute more to this discussion, if you need the support! I really enjoy using Netlify CMS and would love to keep using it for multilingual sites. |
Figured out a workaround for my last comment! Wanted to give an update in case any other devs with the same issue find this thread. I got my pages to route to
Notes on referencing i18n pages using links set in the CMS:
Not sure how this transfers to Gatsby, but I'll be testing it soon! I'd be happy to share my process in this thread, since it seems to be the place to talk about i18n compatibility between Netlify CMS and different SSGs. If this isn't the right place for sharing workarounds, lmk where to go :) |
Just getting to grips with the Beta i18n capabilities and really like the
multple_folders
andmultiple_files
structures. However, I am confused by the decision to only support asingle_file
structure for file collections. I say this reservedly as, clearly, a lot of work must have gone into providing the i18n capabilities and therefore this is in no way a critisism and, quite possibly, may be down to a misunderstanding on my part. The problem that I have though is generating pages in gatsby-node when the i18n implementation involves a mixed structure ofmultiple_files
(i.e. for templated content such as blog posts, product entries etc.) andsingle_file
for one off pages (i.e. index, about, contact).I'd like to see file collections also support a
multiple_files
structure as that would allow a singlecreatePage
mechanism in gatsby-node to be used. Naturally, that would require a single markdown file for language-specific page, using locale as the differentiating factor i.e. index.en.md, index.de.md, index.es.md and so on.If this isn't technically viable, please advise how to go about page generation in gatsby-node when confronted with both
multiple_files
andsingle_file
collections.Thanks in advance for your help!
The text was updated successfully, but these errors were encountered: