How Jekyll sets its site.posts variable

I am trying to create a multilingual page with jekyll and it has been drawn to my attention, how does jekyll goes through the project structure to select posts and assign those to the site.posts variable.

The reason I am asking is that I created the en/_posts folders for posts in English. Added some .md files to the folder and they are still accessible in sites.posts. I thought the _posts folder in the root directory was uniquely to identify files for the sites.posts variable, however, creating subfolders (/en/_posts) will also make files to be read by jekyll and classify those as sites.posts as well. I think the straight answer would be that jekyll is looking for folders called _posts in every single directory and subdirectory of inside a jekyll project. Is that correct?

Yes, that is correct.
site.posts is the container for all the posts in a given site.
en/_posts/2019-10-17-title.markdown will be initialized as a post with category set to "en".
If you were to iterate through site.categories.en, you’ll find all such posts.

1 Like