我使用jekyll构建的mmistakes/minimal-mistakes来构建我的github页面。
我想在_pages/android.html的_posts/android下列出我所有的帖子。也就是说,我想把2016-09-01-aaa.md、2016-09-02-bbb.md和2016-08-26-ccc.md放在_pages/android.html中,而不是放在2016-09-03-ddd.md中。
下面是我的项目的目录结构:
.
├── _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这是_pages/android.html
(但是它会列出_posts下的所有帖子,我怎么才能只列出_posts/android下的帖子呢?)
---
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 %}这是_include/base_path
{% if site.url %}
{% assign base_path = site.url | append: site.baseurl %}
{% else %}
{% assign base_path = site.github.url %}
{% endif %}下面是2016-09-01-aaa.md:(其他帖子与此类似。)
---
title: aaa
categories: /android/third-party/
---
write some contents.下面是_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那么,我怎么才能做到呢?我真的不擅长html和jekyll之类的东西。
发布于 2016-09-06 19:01:56
正如here所说的,下面的代码应该可以工作:
{% for post in site.categories.android %}
{% include archive-single.html %}
{% endfor %}使用如下声明的类别:
categories: android third-party发布于 2018-05-20 22:25:31
post.path将列出_posts/android子文件夹中的所有帖子
{% for post in site.posts %}
{% if post.path contains 'android' %}
{% include archive-single.html %}
{% endif %}
{% endfor %} https://stackoverflow.com/questions/39346102
复制相似问题