The OP tom-mai78101 comments the the article "Jekyll Blog From a Subdirectory" from Hemanth.HM
has confirmed my guesses that subdirectories are only defined by the permalinks in the Markdown files, and not through the folders within the repository.
I quickly wrote a code snippet, and created a few Markdown files shown here, I am now able to create webpages using Markdown files nested within the _posts
folder.
In short, there's no need to use collections in the _config.yml
, and just use the default _posts
.
It would've been better if there is a way to change the default permalink setup in the _config.yml
.
The question "Jekyll not generating pages in subfolders" could be relevant, in order to make some pages being generated in a subfolder.
Or you could use a different baseurl. (Jekyll 1.0+)
Or use the _include
folder (see "Jekyll paginate blog
as subdirectory")
Or, The article "Running Your Jekyll Blog from a Subdirectory" (from Josh Branchaud) seems to address your situation:
Solution 1
Create a directory called blog
in your public html directory (that is, in the directory that your domain points to).
Assuming you are using some sort of deployment scheme (GitHub pages or deployment methods), you need to have that deployment scheme tell Jekyll to deploy to the blog
directory instead of the directory it is currently using.
(in your case blog
would be projects
)
Solution 2
Start by creating a directory locally where you have your Jekyll blog
setup.
This directory will sit along side _posts
, _site
, css
, etc.
This is only going to hold non-post files such as index.html
.
The blog
posts will still go in the _posts directory.
Next, we are going to tell Jekyll that we want it to take our blog posts and put them inside a directory called blog when it generates them.
This can be done by adding a permalink setting to the _config.yml
file.
Add a line like this to the top of the file:
permalink: /blog/:categories/:year/:month/:day/:title.html.
The default (which you have probably been using) puts posts
in a directory structure starting with the category, followed by the date, and finally with the title of the blog post as the name of the html file.
Which, spelled out would be
/:categories/:year/:month/:day/:title.html.
Does that look familiar? Sure does. It is what we have used above, sans the /blog
part.
We are essentially emulating the default directory structure and while adding our blog
directory at the beginning.
Lastly, you are going to want to add an index.html
file to the blog
directory that you created.
This way, when a person goes to mydomain.com/blog/
they can see what blog
posts you have to offer.
This index page is going to more or less mirror exactly what you had setup originally for listing your blog
posts.