Jekyll pedals for messages and other sections

I have been using Jekyll for more than 3 months. I made some blogs with him, but I have one question that I could not find anywhere.

To display all your posts, all markup files in _posts, I use a for loop like this, for example:

{% for post in site.posts %} {{post.title}} {% endfor %} 

I want to do the same with my projects. I created the _projects folder and tried to display them using:

 {% for project in site.projects %} {{project.title}} {% endfor %} 

But Jekyll does not seem to recognize the _projects folder. What should I do to get the same results?

+4
source share
2 answers

This is not how personalized mail types work in Jekyll. However, you can put the _posts directory in another directory and create your own categories this way.

Suppose your projects are organized under projects/_posts , then your template should look something like this:

 {% for post in site.categories.projects %} {{ post.title }} {% endfor %} 

Found it in Jekyll Github Problems

+6
source

Now we are the Jekyll Collections

"Add the following files to your _config.yml site, replacing my_collection with the name of your collection.

For example, you should add:

 collections: - projects 

Then, of course, you can use it in your template in the simplest way:

 {% for project in site.projects %} {{project.title}} {% endfor %} 
+1
source

Source: https://habr.com/ru/post/1485473/


All Articles