The templates of most jekyll
sites contain only one entrance of the blog posts. Usually, this entrance is placed in the homepage
of the site.
One might somehow want to separate the homepage
and the blog
, or add some extra blog
s to meet various usage.
This can be achieved, following this instruction to revise the jekyll
structure and posts’ header.
Typical jekyll
structure
Here is an example of the structure of a jekyll
site with a single blog at the index
page, and the markdown
blog files are in /_posts/
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/_includes/
|---head.html
|---sns-links.html
|---footer.html
/_layouts/
|---default.html
|---post.html
/_posts/
|---time-title.md
/img/
|---bg.jpg
index.md or index.html
about.md or about.html
And the info in a blog post header is:
1
2
3
4
5
layout: post
title: "TITLE"
author: "AUTHOR"
date: "YYYY-MM-DD HH:mm:ss"
description: ""
Seperate the Homepage and Blog
The revised structure would be:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/_includes/
|---head.html
|---sns-links.html
|---footer.html
/_layouts/
|---default.html
|---post.html
/img/
|---bg.jpg
/blog/
|---index.html
|---/_posts/
|---time-title.md
index.md or index.html
about.md or about.html
Just move all the blog pagination
functions in ./index.html
to /blog/index.html
.
To activate the page of blog, category
is added into the markdown
post header.
1
2
3
4
5
6
layout: post
title: "TITLE"
author: "AUTHOR"
date: "YYYY-MM-DD HH:mm:ss"
description: ""
category: blog
Add Extra Blogs
Similarly, you will change the structure into:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/_includes/
|---head.html
|---sns-links.html
|---footer.html
/_layouts/
|---default.html
|---post.html
/img/
|---bg.jpg
/blog1/
|---index.html
|---/_posts/
|---time-title.md
/blog2/
|---index.html
|---/_posts/
|---time-title.md
index.md or index.html
about.md or about.html
The posts for blog1
should have the headers as:
1
2
3
4
5
6
layout: post
title: "TITLE"
author: "AUTHOR"
date: "YYYY-MM-DD HH:mm:ss"
description: ""
category: blog1
And the posts headers for blog2
should be alike:
1
2
3
4
5
6
layout: post
title: "TITLE"
author: "AUTHOR"
date: "YYYY-MM-DD HH:mm:ss"
description: ""
category: blog2
Notification
- The
/_posts/
is not needed to be set in theblog1
orblog2
. It can be put in the root directory as./_posts/
.