Jekyll -- create another folder with similar functionality of _posts
Asked Answered
W

3

5

I have a _posts folder that contains all my posts for my blog and projects. I'd like to separate the markdown files for my blog notes and project pages. For example, in addition to the built-in md -> HTML conversion for files in _posts, I'd like to have a _projects folder that contain my markdown files for individual project write-ups and build them into HTML when running jekyll serve.

Wade answered 23/7, 2017 at 1:30 Comment(0)
F
2

Looks like you want to use categories. Here is a link discussing a similar problem : Multiple _posts directories

Faze answered 23/7, 2017 at 3:16 Comment(2)
I couldn't get this to work, but it prompted a hacky idea I implemented, which works. I separated my notes and projects files into two subdirectories in _posts. From there, I added a layout tag to the front matter for each of these, which served to identify whether or not it was a note or project file. To display all projects in my projects overview page, I used this{% for post in site.posts %} {% if post.layout == "project" and post.status == "in-progress" %}Wade
@JasonBak _posts folder shouldn't contain subdirectories.Prase
L
9

just define a collections key in your _config.yml:

collections:
  projects:
    output: true

Official docs for more info..

Lauralauraceous answered 23/7, 2017 at 2:57 Comment(0)
P
2

By default Jekyll will ignore new folders with an underscore prefix, so you can't use _projects.

You can separate _posts in several folders, to have all your project files in a specific folder, create projects/_posts folder structure and move your project files inside projects/_posts, leaving blog posts in _posts.

Jekyll will generate each post and automatically assign the project category to them, so you can also generate different lists from your blog posts.

Prase answered 23/7, 2017 at 3:13 Comment(0)
F
2

Looks like you want to use categories. Here is a link discussing a similar problem : Multiple _posts directories

Faze answered 23/7, 2017 at 3:16 Comment(2)
I couldn't get this to work, but it prompted a hacky idea I implemented, which works. I separated my notes and projects files into two subdirectories in _posts. From there, I added a layout tag to the front matter for each of these, which served to identify whether or not it was a note or project file. To display all projects in my projects overview page, I used this{% for post in site.posts %} {% if post.layout == "project" and post.status == "in-progress" %}Wade
@JasonBak _posts folder shouldn't contain subdirectories.Prase

© 2022 - 2024 — McMap. All rights reserved.