Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Option to put default language in subfolder also puts non-translated static contents (img etc.) in subfolder #187

Open
sceee opened this issue Jan 22, 2021 · 11 comments

Comments

@sceee
Copy link

sceee commented Jan 22, 2021

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?

@g-konst
Copy link

g-konst commented Apr 22, 2021

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

@sceee
Copy link
Author

sceee commented Apr 25, 2021

@g-konst which version are you using?

With 1.6.1, the issue occurs as described.

@g-konst
Copy link

g-konst commented Apr 25, 2021

@g-konst which version are you using?

With 1.6.1, the issue occurs as described.

Latest, 1.7

@sceee
Copy link
Author

sceee commented Apr 25, 2021

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"]

@g-konst
Copy link

g-konst commented Apr 25, 2021

@sceee check this please.
https://www.youtube.com/watch?v=s_8KA6FyLjo

@sceee
Copy link
Author

sceee commented Apr 26, 2021

@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:
image

@g-konst
Copy link

g-konst commented Apr 27, 2021

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).

@Heanthor
Copy link

Heanthor commented Dec 4, 2021

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"]

@figgles
Copy link
Contributor

figgles commented Aug 3, 2023

I've configured my site to do exactly what you do with 1.8.0

/en/index.html
/es/index.html
/images/example.jpg

This feature isn't broken. Since this is > 2 years old, I suggest closing the issue.

@LorenzoDelpi
Copy link

@figgles can you share your environment details?
I am trying to replicate the solution but it does not work with my env.

  • Jekyll 4.3.2
  • languages plugin 1.8.0
  • bundler 2.4.18
  • gem 3.4.10

@figgles
Copy link
Contributor

figgles commented Aug 7, 2023

@LorenzoDelpi
Gemfile

source "https://rubygems.org"
gem "jekyll", "~> 4.3.2"
group :jekyll_plugins do
	gem 'jekyll-multiple-languages-plugin'
end
platforms :mingw, :x64_mingw, :mswin, :jruby do
  gem "tzinfo", ">= 1", "< 3"
  gem "tzinfo-data"
end
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby]

_config.yml

# Build settings
plugins:
  - jekyll-multiple-languages-plugin


# Localization
languages: ["en", "es"]
default_locale_in_subfolder: true
exclude_from_localizations: ["assets", "images", "favicon.ico"]

exclude:
  - doc/
  - assets/sass

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants