Html 如何使用jekyll按时间顺序在_posts的子目录中列出我的帖子
我正在使用它与jekyll一起构建我的github页面 我想在Html 如何使用jekyll按时间顺序在_posts的子目录中列出我的帖子,html,yaml,jekyll,liquid,github-pages,Html,Yaml,Jekyll,Liquid,Github Pages,我正在使用它与jekyll一起构建我的github页面 我想在\u pages/android.html中的\u posts/android下列出我的所有帖子。意思是,我想把2016-09-01-aaa.md,2016-09-02-bbb.md和2016-08-26-ccc.md放在页面/android.html中,而不是2016-09-03-ddd.md 以下是我的项目的目录结构: . ├── _config.yml ├── _pages │ └── android.html ├── _
\u pages/android.html
中的\u posts/android
下列出我的所有帖子。意思是,我想把2016-09-01-aaa.md
,2016-09-02-bbb.md
和2016-08-26-ccc.md
放在页面/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
这里是\u pages/android.html
:
# 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
(但它将列出\u posts
下的所有帖子,
我如何才能在\u posts/android
下列出帖子
这里是2016-09-01-aaa.md
:
(其他帖子与此类似。)
下面是\u 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方面的东西。如前所述,以下内容应该有效:
{% for post in site.categories.android %}
{% include archive-single.html %}
{% endfor %}
分类如下:
categories: android third-party
post.path
将列出子文件夹\u posts/android
{% for post in site.posts %}
{% if post.path contains 'android' %}
{% include archive-single.html %}
{% endif %}
{% endfor %}
我试过,
{%forpost-in-site.categories.android%}
不起作用,无论是{%forpost-in-site.posts.android%}
。那些代码没有显示任何内容。@GNCARDARY我认为问题在于你的类别声明。不要使用categories:/android/third-party/
,而是尝试使用categories:android-third-party
您是对的,将类别更改为android-third-party
,并使用代码{%forpost-in-site.categories.android%}{%include-archive-single.html%}{%endfor%}。我第一次核实的时候一定是出了什么问题。非常感谢。
categories: android third-party
{% for post in site.posts %}
{% if post.path contains 'android' %}
{% include archive-single.html %}
{% endif %}
{% endfor %}