Closed madsem closed 3 years ago
Thanks @madsem. Hope it's working out 👍
Interesting. The way I envisage it, the site root (/
) is not a page per se, but the language-agnostic root at which you'd be wanting to redirect users either to a "default" language site (e.g. /en
), or their respective language (if you were basing redirection on Accept-Language
headers, for example).
So your English homepage would be at mydomain.com/en
, as you intend.
What were you hoping to see at the site root, mydomain.com
?
Thanks @madsem. Hope it's working out 👍
Interesting. The way I envisage it, the site root (
/
) is not a page per se, but the language-agnostic root at which you'd be wanting to redirect users either to a "default" language site (e.g./en
), or their respective language (if you were basing redirection onAccept-Language
headers, for example).So your English homepage would be at
mydomain.com/en
, as you intend.What were you hoping to see at the site root,
mydomain.com
?
Hey Adam,
that is exactly how I see it as well, but the default language root should (imho) not include the language. For example for SEO reasons.
URLs should ideally never change, but this becomes a prime candidate to change whenever you switch site builders. The additional languages are a different story, this is additional content you offer and needs some kind of locale appended to the url, whereas the default root doesn't need it.
So I think mydomain.com
should show the content in the default language of the site, without appending the locale.
Btw, I also managed to achieve just this, by keeping my index template out of the locale folder.
I'm implementing Netlify CMS atm also, so there's a lot of change in my directory structure and nothing is final. I just made i18n work with Netlify cms, and realized that when using the CMS the folder structure changes from what is recommended here, to:
_site
---->pages
--->en
--->de
---->articles
--->en
--->de
So I will now most likely try to make my multi-lingual setup work with this dir structure. And also implement a language switcher, somehow haha.
Maybe I can even use yours, I haven't looked all too deep into everything yet.
PS: I would actually even go further, and say that the content in default language should not have a locale appended to the url at all. After all, this is the default language and only translated versions should use a locale.
So for example: mydomain.com
shows home page in english if english is default, mydomain.com/about-us/
shows the english about us whereas mydomain.com/de/about-us/
shows the german version for example.
This would be the cleanest solution I think :)
Appreciate more detail, @madsem.
...additional content you offer and needs some kind of locale appended to the url, whereas the default root doesn't need it.
I think this is the central assumption where this plugin might be coming off course for you. It's built around the assumption that, for consistency, each "language site" should exist under a language subdirectory.
I see what you mean re: URLs not changing. In theory here, that wouldn't necessarily be the case when switching site builders, but certainly would be if you were moving from a single language site (/
being "default" English, for example), to a multilingual site (where English would then live at /en
). I can see this happening in quite particular circumstances (e.g. if you're dealing with a legacy site trying to retro-fit multilingual, or should requirements change after development has commenced), though I concede that's a pretty significant change, which would require broader migration considerations (redirects, canonical links, etc.).
I've not had the chance to play with NetlifyCMS yet, but it's interesting that it recommends a folder structure that puts locale at the end of the URL path. Do you have a reference for this, out of interest?
Good luck on the dir structure and language switcher. A good blog post on the topic, and some additional thoughts here, if they're handy.
Sounds as though you're on your way to a solution. Happy to close this ticket?
This can be accomplished using permalink, I have just set up a site this way. What I did was mark each page of the default language site with a permalink, added a new variable to each locale json file (e.g. en-us.json) with a locale_directory variable. (using "/" for default language and /{{ locale }}/ for each locale). Finally update all links so that you use {{ locale_direrectory }} instead of the normal {{ locale }} and make sure to remove any slashes in on either side of the call. (e.g. href="{{ locale_directory}}about/" for /about/ or /es-es/about/, etc. and just href="{{ locale_directory }}" for the homepage)
Hey there,
great plugin and explanation how it all fits together! :)
I'm in the process of building a starter theme, which should have i18b baked in.
Now I realized that the default language of the site will always contain the locale at the end of the url, which imho shouldn't be like that.
I.E: mydomain.com is in english, and it's homepage will now always be at mydomain.com/en/
Is there any way to prevent this? I'm open to make a PR as well.