jekyll-multiple-languages-plugin
jekyll-multiple-languages-plugin copied to clipboard
Option to put default language in subfolder also puts non-translated static contents (img etc.) in subfolder
In the past, I used the setup I also described here: Have a default language be put to root and in a separate language folder:
index.html // English index
en/index.html //English index - equals root index.html
de/index.html //German index
Since #170 , it seems there is no way to put the default language to a subfolder but keep static assets in the root. E.g.
/img/test.jpg
/en/index.html
/de/index.html
It seems that everything specified in
exclude_from_localizations: ["js", "img", "css", "fonts"]
is still put in the default languages's folder:
/en/index.html
/en/img/test.jpg
/de/index.html
Of course, I read in the docs that those files should be referenced using a prepend like
<link rel="stylesheet" href="{{ "/css/bootstrap.css" | prepend: site.baseurl_root }}"/>
Unfortunately, this only works well for html/md files.
In my case, I reference font files (.woff) in sass files - after some googling, it turned out that you cannot simply use {{ "/fonts/myfont.woff" | prepend: site.baseurl_root }} in sass files as there are some restrictions that this can only be used in a top-level sass file.
So overall, it seems very complicated for a fairly simple thing - I just want all my static assets be on the root so I have a structure like this:
/img/test.jpg
/en/index.html
/de/index.html
and can just reference those files with a regular <link rel="stylesheet" href="/css/bootstrap.css"/>.
Is there any possibility to still configure the plugin to produce an output like this with the 1.7 release?
With following settings in _config.yml:
languages: ["en", "ru"]
exclude_from_localizations: ["js", "images", "assets"]
default_locale_in_subfolder: true
I get next _site structure:
/images/..
/js/..
/assets/css/..
/en/index.html
/ru/index.html
So it seems to work.
If you set default_locale_in_subfolder to false, it will be the same except for the en folder, because these files will be at the root:
/images/..
/js/..
/assets/css/..
/index.html
/ru/index.html
@g-konst which version are you using?
With 1.6.1, the issue occurs as described.
@g-konst which version are you using?
With
1.6.1, the issue occurs as described.
Latest, 1.7
So even if I use 1.7.0 with your config settings, it's not working:
Output directory then only contains
de en
and misses css etc. directories.
Config is:
languages: ["en", "de"]
default_locale_in_subfolder: true
exclude_from_localizations: ["public", "js", "img", "css", "fonts"]
@sceee check this please. https://www.youtube.com/watch?v=s_8KA6FyLjo
@g-konst thanks for the video but it seems to behave differently on my side. I don't know why it's working on your side but not on mine. But since two other people also upvoted this, I guess they also ran into this issue.
In the end, it just looks like this if I use 1.7.0:

Try disabling all themes or plugins, perhaps one of them overwrites some of the config options. Or to put it another way, try building your project using a different OS (maybe in docker).
Bumping with a related fix: I also ran into this same problem, however I am using a custom source directory. With the config setting source: ./src I had to also include that path in the exclude options:
exclude_from_localizations: ["src/images", "src/css"]