Reputation: 149
I'm using mmistakes/minimal-mistakes which is build with jekyll to build my github pages.
I want to list all of my posts under _posts/android
in _pages/android.html
. Meaning, I want to put 2016-09-01-aaa.md
,2016-09-02-bbb.md
and 2016-08-26-ccc.md
but not 2016-09-03-ddd.md
in _pages/android.html
.
Here is my project's directory structure:
.
├── _config.yml
├── _pages
│ └── android.html
├── _posts
│ ├── android
│ │ ├── third-party
│ │ │ ├── 2016-09-01-aaa.md
│ │ │ └── 2016-09-02-bbb.md
│ │ └── handler
│ │ └── 2016-08-26-ccc.md
│ └── java
│ └── effective-java
│ └── 2016-09-03-ddd.md
└── _site
├── index.html (my github home page)
├── android
│ ├── index.html (generated from "_pages/android.html")
│ ├── third-party
│ │ ├── aaa
│ │ │ └── index.html
│ │ └── bbb
│ │ └── index.html
│ └── handler
│ └── ccc
│ └── index.html
└── java
└── effective-java
└── ddd
└── index.html
Here is _pages/android.html
:
(But it will list all the posts under _posts
,
How can I make it list posts under _posts/android
only ?)
---
layout: archive
permalink: /android/
excerpt: "android"
author_profile: false
sidebar:
nav: "android"
---
{% include base_path %}
<h3 class="archive__subtitle">{{ site.data.ui-text[site.locale].recent_posts | default: "Recent Posts" }}</h3>
{% for post in site.posts %}
{% include archive-single.html %}
{% endfor %}
Here is _include/base_path
:
{% if site.url %}
{% assign base_path = site.url | append: site.baseurl %}
{% else %}
{% assign base_path = site.github.url %}
{% endif %}
Here is 2016-09-01-aaa.md
:
(Other posts is similar to this.)
---
title: aaa
categories: /android/third-party/
---
write some contents.
Here is the snippet of _config.yml
:
# Site Settings
locale : "zh-CN"
title : "IT Tech"
title_separator : "-"
name : "TesTName"
description : "Android Java HTML CSS JavaScript Ubuntu"
url : "http://localhost:4000" # the base hostname & protocol for your site e.g. "https://mmistakes.github.io"
baseurl : # the subpath of your site, e.g. "/blog"
# Defaults
defaults:
# _posts
- scope:
path: ""
type: posts
values:
layout: single
author_profile: true
read_time: false
comments: true
share: true
related: false
# _pages
- scope:
path: ""
type: pages
values:
layout: single
author_profile: true
related: true
So, how can I make it ? I'm really not good at the html and jekyll things.
Upvotes: 3
Views: 1821
Reputation: 10701
The post.path
will list all your posts in subfolder _posts/android
{% for post in site.posts %}
{% if post.path contains 'android' %}
{% include archive-single.html %}
{% endif %}
{% endfor %}
Upvotes: 1
Reputation: 15976
As stated here, the following should work:
{% for post in site.categories.android %}
{% include archive-single.html %}
{% endfor %}
With categories declared like this:
categories: android third-party
Upvotes: 1