-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Add multilingual multihost support #4027
Comments
Thank you for organizing this @bep. An aside: the I can think of these things:
|
Yes, Hugo is all UTF-8 and I'm pretty sure what we do no "normalization" of the As to |
thanks @bep. I think I confused things. I meant to say, if the port is set on the CLI, then hugo would need to increment up from that.
... would get you 1317, 1318 etc, if you have multiple baseURLs specified in the config. Regarding typekit needing a local domain, I did not know that, and just specified "localhost" and "127.0.0.1" in the typekit "kit editor" setup, for my sites that use typekit. It seems to work... |
Yes, that works too, I guess, but having a "secret domain" prevents others from using my subscription. Not a big thing. And yes; I agree about the incremental port thing. |
ah, never thought of that. Uh oh! |
Just to complete that thought. I have something like this in /etc/hosts: 127.0.0.1 somename.local And then I do Which I will make sure works also in a multihost setup (http://somename.local:1313, http://somename.local:1314 etc.). |
@RickCogley I'm back from Spain and about to wrap my head around finishing this implementation. One remark: We may refine this in the future, but my first take on the |
Welcome back @bep. Hope you got to relax & enjoy. :-) Yeah, I can see duplicating |
@RickCogley I have a better idea. I will revise my first post to include this. |
@RickCogley I have updated the description with a new section about this. I think this will be very valuable, not just for this particular feature. |
@bep, the current description lists this config block (with irrelevant elements removed): [languages]
staticDir = "static_no"
[languages.no]
[languages.en]
staticDir = "static_en" Did you mean to include |
Copy and paste mistake. Thanks for spotting. |
@bep that sounds slick. Given the same file in say Also, are the rules different if, say, they have the same filename but one is newer?
|
In my head: In the above case, no files in The "righ most" is for the Japanese site the
No. |
@RickCogley considering #2699 it may (at least for the content part) make sense to let both "language folders" be visible to both -- but in the static case the current language will always win on duplicates. Will think. |
This commit adds multihost support when more than one language is configured and `baseURL` is set per language. Updates gohugoio#4027
This commit adds multihost support when more than one language is configured and `baseURL` is set per language. Updates gohugoio#4027
@bep If you set:
... do you also have to add the language static dirs like
Or are those set under the language blocks only? In a multilingual site, in my experience you have images that are language specific but, you also have images that are common to both. So I suppose, common ones go into "global static" and language specific go into "language specific" correct? |
Yes.
Yes. The use case for having a "static_no" is typically for assets that are different between the two languages: Logo (text in the particular language), maybe also CSS files per language, whatever. |
Ok, it seems clean / good to me. |
How about staticLangDir?
|
I have slept on this, and I think I have figured out a good way to differentiate override these static dirs vs add these static dirs. It will behave conceptually a little different when running in multihost mode vs regular, but I think it should be logical for most people. If you need more staticDir properties, add an ID as suffix. An ID is a integer between 1 and 10. So: staticDir = ["static1", "static2"]
[languages]
[languages.no]
staticDir = ["static1"]
staticDir2 = "static_no"
baseURL = "https://example.no"
languageName = "Norsk"
weight = 1
title = "På norsk"
[languages.en]
staticDir2 = "static_en"
baseURL = "https://example.com"
languageName = "English"
weight = 2
title = "In English" The above shows a mix of override and additions. For no: "static1", "static_no" In both of the above, the right-most directory will win on duplicates. |
Oh, smart!
|
This commit adds multihost support when more than one language is configured and `baseURL` is set per language. Updates gohugoio#4027
This commit adds multihost support when more than one language is configured and `baseURL` is set per language. Updates gohugoio#4027
This commit adds multihost support when more than one language is configured and `baseURL` is set per language. Updates gohugoio#4027
This commit adds support for multiple statDirs both on the global and language level. A simple `config.toml` example: ```bash staticDir = ["static1", "static2"] [languages] [languages.no] staticDir = ["staticDir_override", "static_no"] baseURL = "https://example.no" languageName = "Norsk" weight = 1 title = "På norsk" [languages.en] staticDir2 = "static_en" baseURL = "https://example.com" languageName = "English" weight = 2 title = "In English" ``` In the above, with no theme used: the English site will get its static files as a union of "static1", "static2" and "static_en". On file duplicates, the right-most version will win. the Norwegian site will get its static files as a union of "staticDir_override" and "static_no". This commit also concludes the Multihost support in gohugoio#4027. Fixes #36 Closes gohugoio#4027
This commit adds multihost support when more than one language is configured and `baseURL` is set per language. Updates #4027
@bep Is it possible to add custom Google Analytics ID for each language domain? And if not, when it can be implemented? |
@biodranik you can set site params per language |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
The current multilingual support in Hugo is restricted to 1
baseURL
, i.e. the languages are put into subfolders named after the language code (the default language may be kept on the top level), i.e.https://example.com/en
etc.This works great and is possibly the most common use case.
This does, however, not allow using the
baseURL
to differentiate the languages, i.e.https://en.example.com
,https://jp.example.com
and similar variations.Core Changes
This issue describes a way to define a
baseURL
perlanguage
. The new rule will be:Example:
With the above, the two sites will be generated into
public
with their own root:The important part here is that:
All URLs (i.e
.Permalink
etc.) will be generated from that root. So the English home page above will have its.Permalink
set tohttps://example.com/
.Hugo Server
The changes above will work for the regular
hugo
; the two sites will be ready to be configured as two virtual hosts in Nginx or similar.But you'd want to test it before you go live, of course. So we need to adapt
hugo server
to also handle multiple base URLs.This issue suggests that we start as many HTTP servers as there are languages. Which, in its default port settings will just increment from port 1313 and get:
Then you can navigate the sites (i.e. jump from article to its translations etc.) just as it was deployed live on your production environment.
Multiple content and static dirs
Also see #4073 and #3757
With the new deployment topology this new feature creates, you often end up wanting better control of your
content
and yourstatic
files.We will improve on this on two levels:
staticDir
can now be a slice of strings.staticDir
settings.staticDir
entries can be added by adding a ID from 1..10 to the key, e.g.staticDir1
. This can be useful if you want to keep the global static dirs settings, but have one or more additional directories for a specific language.All the static directories will create a union filesystem from left to right:
theme static dir, global config static dirs, language static dirs.
Example:
In the above, with no theme used:
The text was updated successfully, but these errors were encountered: