Hexo: Pin an article to the top

Created on 20 Jan 2018  ·  3Comments  ·  Source: hexojs/hexo

I wonder how to pin some articles to the top, others still ordered by date

Hope it can be officially supported~

Most helpful comment

just add a property in the frontmatter of your Markdown file, i.e.

title: Some TItle
date: 2018/01/01 00:00:00
categories:
- Category 1
pinned: true
---
xxx

and edit your template file as follows (using jade as example)

- page.posts.each(function (item) {
        if post.pinned
                renderPost()
- })
- page.posts.each(function (item) {
        if not post.pinned
                renderPost()
- })

All 3 comments

just add a property in the frontmatter of your Markdown file, i.e.

title: Some TItle
date: 2018/01/01 00:00:00
categories:
- Category 1
pinned: true
---
xxx

and edit your template file as follows (using jade as example)

- page.posts.each(function (item) {
        if post.pinned
                renderPost()
- })
- page.posts.each(function (item) {
        if not post.pinned
                renderPost()
- })

That is a good idea, thank you, and I've also found another solution

Close as reloved.

Was this page helpful?
0 / 5 - 0 ratings