ddypjj
January 28, 2021, 11:47am
1
I am new to Jekyll. I want to build a site from scratch.
I want to have articles which grouped into some folders.
I have navigation like this
name: Home
link: /
name: Cook
link: /cook.html
name: Blog
link: /blog.html
name: Diary
link: /diary.html
I want have folder for each menu. And if i click one of them it will show the list for each articles in that folder.
is that possible by creating folder _cook, _blog, _diary and make page cook.html, blog.html, and diary.html and do for looping?
Thank you guys
1 Like
Do you want pages to be
/
/cook/ # ie /cook/index.html
/cook/abc.html
/cook/def.html
/blog/
/blog/...
...
That would be more typical in web standards than /cook.html
and /cook/abc.html
mixed.
PS. Jekyll already has support for blog posts so look at Posts in the docs. A standard theme typically comes with a for loop that shows all pages on the homepage
e.g. Jekyll Blog Demo | Base for a static website blog - built with Jekyll and the default theme
Have a look at the 10 step intro tutorial in Jekyll docs
Once you understand how to setup the basic pages, you can use Collections.
You’ll be able to iterate over pages here.
_cook/
abc.md
def.md
And put them all on a list on /cook/
Using
{% for p in site.cook %}
- [{{ p.title }}]({{ p.url | relative_url }})
{% endfor %}
Result
For example I have a shows collection here
And the list page here with permalink /shows/
. I put the file as _pages/shows.md
but shows.md
in the root works too.
---
title: Shows
permalink: /shows/
---
<ul class="shows-list">
{% assign sorted_shows = site.shows | sort: 'date' | reverse %}
{% for show in sorted_shows %}
<li>
<h2 class="post-title p-name">
<a href="{{ show.url | relative_url }}">
{{ show.title }}
</a>
</h2>
<p class="post-meta">
{{ show.date | date: "%b %-d, %Y" }}
</p>
<p>
{{ show.excerpt }}
</p>
This file has been truncated. show original
Result:
ddypjj
January 30, 2021, 1:34am
5
Thanks @MichaelCurrin this is what i am looking for
1 Like