5 分钟上手
这一页用最短路径跑通一个 docs 模式站点。假设你已经装好主题(见安装与部署)。
第 1 步:切换模式
编辑 themes/xfm/_config.yml:
第 2 步:配置站点信息
编辑站点根目录 _config.yml:
1 2 3 4 5
| title: 我的产品文档 subtitle: 稳定版 v1.0 author: 你的名字 url: https://docs.example.com language: zh-CN
|
再回到 themes/xfm/_config.yml 配置品牌与外观:
1 2 3 4 5 6 7 8 9 10
| logo: tagline: 面向开发者的产品手册 avatar: /images/avatar.svg favicon: /images/favicon.svg
appearance: scheme: auto primary: "#4f6bed" radius: normal glass_navbar: true
|
第 3 步:写第一篇文档
创建 source/docs/xfm/getting-started/index.md:
1 2 3 4 5 6 7 8
| --- title: 快速上手 order: 1 ---
# 快速上手
这里写你的第一篇文档内容。
|
目录名即
文件放在 source/docs/xfm/getting-started/index.md,访问路径就是 /docs/xfm/getting-started/。侧边栏 path 必须与此严格对应。
第 4 步:定义文档侧边栏
创建 source/_data/docs.yml:
1 2 3 4
| - title: 入门 children: - title: 快速上手 path: /docs/xfm/getting-started/
|
不做这一步也能跑:当 _data/docs.yml 不存在时,主题会自动扫描所有页面,按 order 加 title 排序生成侧边栏。只是自动生成的树是扁平的,正式文档建议显式定义。
第 5 步:预览
打开 http://localhost:4000/docs/xfm/getting-started/,你会看到三栏布局:左侧文档树、中间正文、右侧目录。
接下来做什么
配置全站
配置总览 逐项说明 _config.yml。
丰富内容
标签插件 提供提示块、选项卡、时间轴等扩展语法。
调整响应
三档配置 定制手机 / 平板 / 桌面表现。
一个典型的最小配置
把下面这段贴进 themes/xfm/_config.yml,就是一个可用的文档站起点:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| mode: docs
appearance: scheme: auto primary: "#4f6bed" radius: normal
navbar: enable: true sticky: true auto_hide: true
menu: 首页: path: / icon: home 文档: path: /docs/ icon: file-doc 归档: path: /archives/ icon: archive
docs: data_file: docs expanded: true auto_expand: true page_nav: true last_modified: true toc: true
search: enable: true hotkey: true
post: toc: true toc_depth: [1, 2, 3]
footer: enable: true statistics: true
|
评论