實際效果可參考我的網站作品 Jazz LeadSheets
此 Shortcode 為使用在 Hugo 之中,他能夠抓取你在 content/post/ 下的所有文件,並依照 "Title" 的字母順序排列,包含以下功能:
- 可以抓取所有 content/post/ 下的文件的標題。
- 建立標題開頭的字母分類。
- 點擊文章標題後可以跳轉到該文章的網址。
請下載這份檔案 list-post 並將他放在你 Hugo 網站的根目錄的 layouts/shortcodes 底下
接著在你的 markdown 文件中(例如 index.md) 引用此 shortcode {{< list-post >}},即可實現列出所有文章標題與連結功能。
---
title: All post by Alphabet
---
{{< list-post >}}You can see a working example on my project site: Jazz LeadSheets
This shortcode is designed for use with Hugo. It retrieves all documents under the content/post/ directory and sorts them alphabetically by "Title". It includes the following features:
- Retrieves the titles of all documents under
content/post/. - Groups titles by their starting letter.
- Clicking on a post title navigates to its corresponding URL.
Download this file: list-post and place it in your Hugo site's root directory under layouts/shortcodes.
Then, in your Markdown file (e.g., index.md), use the shortcode {{< list-post >}} to list all post titles and links.
---
title: All post by Alphabet
---
{{< list-post >}}