关于

如何创建教程或笔记

Academic v5 版本开始支持 book 类型,用来替代 v4 及之前的 docs 类型。

该类型被设计用作 知识分享,例如:在线教程,电子书,笔记,基础教程,软件文档,知识仓库等。

你现在看到的页面就是用的 book 页面布局。

组织内容

推荐按照下面的结构来组织文件:

content/course
├── _index.md         # Overview
└── intro             # Chapter folder
    ├── _index.md     # Chapter metadata including chapter title
    ├── example1.md   # A page
    └── example2.md   # Another page
└── tutorial          # Another chapter
    ├── _index.md
    ├── intro.md
    └── ...

文件夹和文件的名字中不要留空格,如有必要请使用短横,例如:my-course。

本例中的 course 文件夹名可以根据内容自定义,例如,如果是写书,可以命名为 book,如果是写文档,可以命名为 docs;如果是记笔记,可以命名为 notes。

元数据

在 Chapter 文件夹下的 _index.md 文件中的 front matter 中可以编辑以下元数据:

# Page title
title: An Example Course

# Title for the menu link if you wish to use a shorter link title, otherwise remove this option.
linktitle: Course

# Page summary for search engines.
summary: Blah, blah, blah...

# Date page published
date: 2018-09-09

# Academic page type (do not modify).
type: book

# Position of this page in the menu. Remove this option to sort alphabetically.
weight: 1

菜单

相较于之前的 docs 类型,book 类型的菜单定义简化了很多,有以下 3 种方式排列:

  • 按标题顺序
  • 按标题逆序
  • 通过设置权重,如 weight: 10, 人为设置顺序,数字越小的顺序越靠前
    • 建议权重值的增幅以 10 为单位,这样假如在未来你想插入新页面或者重新排序时,无需更改所有页面

内容页(Pages)

每一章(Chapter)文件夹下可以有任意多的页面(Pages),每个页面都应该包含:

  • title,标题
  • type,固定值为 book

title 作为页面标题会出现在页面的头部,默认情况下也会出现在菜单项链接。可以使用 linktitle 重新定义一个专门用于菜单链接的标题。

默认情况下,页面的右边栏会根据内容的 heading 自动生成目录,如果不想展示目录,需要设置 toc 为 false。

如果想要在页面底部展示翻页按钮,在 params.toml 中设置 docs_section_pager 为 true 即可。页面间的顺序同样由 weight 决定。

示例如下:

---
title: Example Page 1
date: 2019-05-05
type: book
---

Content...

要展示本章下子页面列表,使用 {{< list_children >}} shortcode。

下一页