Can't seem to get Jekyll to see posts that are in subdirectories from the root folder

若如初见. 提交于 2019-12-04 20:48:39
VonC

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.

Edit : My first answer was completely wrong. I was talking

_config.yml

collections:
  project:
    output: true

_project/project_1.md

---
layout: project
title: project
---

## Yo!

Project in **strong** yo `inline code`

    some code
    yolo !

_layouts/project.html

<!DOCTYPE html>
<html>
  {% include head.html %}
  <body>
    {% include header.html %}
    <div class="page-content">
      <div class="wrapper">
        {{ content }}
      </div>
    </div>
    {% include footer.html %}
  </body>
</html>

You now have a project/project_1.html page.

No need to use include: parameter in order to Jekyll to see collection folder or subfolder.

exclude: parameter can be used to ignore a subfolder in the collection.

End Edit


Old answer (nothing to do with collection)

Your _project folder is ignored by Jekyll, just like any underscored folder

To force Jekyll to parse files in this folder, in your _config.yml you can add :

include:
  - _project

jekyll build and all is good !

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!