untra/polyglot

tree structure incorrect

julienguegan opened this issue · 7 comments

Hi !

I have set up jekyll-polyglot but the tree structure generated in _site seems incorrect to me :

├── _site
├── en/
│   ├── home
│   └── posts/
│       └── en/
│           ├── post1
│           └── post2
├── home
└── posts/
    ├── post1
    └── post2

As you see, for the english language en, inside the posts directory there is another en directory a second time. From my understanding, this one should not exists ...

Does someone encounter the same problem ? Is it normal ? If not, what can I do ?

Thank you for your help !

========================================================

Note that in my root folder, the _posts looks like this :

└── posts/
    ├── en/
    │   ├── post1
    │   └── post2
    └── fr /
        ├── post1
        └── post2
untra commented

Hi @julienguegan ,

That tree structure is intentional, so your default lang (in this case fr) is the top level language users of site visit, and all other en posts are namespaced under en.

For example the polyglot en about page is at https://polyglot.untra.io/about but the french page is at https://polyglot.untra.io/fr/about .

Hopefully this makes sense. An alternative I've seen some users do is to specify a different default_lang that is not listed in your langs, which will generate the site tree as you expect (but then you will need to handle what happens to pageroutes like /about with no language prefix).

edit: might be something else going on with your setup. I'm happy to take a look at your repo if you shoot me a link .

Ok I will try because I was expecting to not have the redundant en inside of posts. Because with that the language switcher does not work (and I am not fluent enough in liquid to adapt it)

As I'm new to Jekyll and polyglot and found this post pertinent, I've a pertinent question to the output.
How can I do ensure that each language is wrapped under its own lang folder?

I have multilingual site, but I want to build them in isolation, so whatever is in /en/ is seen only in that corresponding built version, whatever in the other languages following suit.

I tried both the following optiions

├─ posts/
      ├── post1-en.md
      └── post2-fr.md
├─ posts/
      ├── en/ 
       |         └── post1-en.md
      ├── fr/
                 └── post2-fr.md

However, the default_lang is always rendered in the root node.
Thanks

untra commented

@andreamoro a solution is to specify a default_lang that is not among the listed langs, or is empty.

languages: ["en", "fr"]
default_lang: ""

the site will still build, but most of the built site will be under the specified languages, with only pages without specified lang frontmatter still building under the root directory. You are then free to do whatever post-processing you want from there.

@untra, I'm reading your last comment, I quote:

with only pages without specified lang frontmatter still building under the root directory.

All my pages have the lang attribute in their front matter, but if I set the default_lang as empty, I still have pages generated in the root folder. Do you have an idea why it is so?

@hacketiwack without access to your code repo I do not, and cannot give any suggestions there.

closing this issue for the age.

It works now.
I've just found why.
By empty, you meant default_lang: and not default_lang: '' or default_lang: "".