写作指南
写作指南
本站用 Hugo 生成,主题是 Hextra。所有内容都是 content/ 目录下的 Markdown 文件。
目录结构
- _index.md
- _index.md
- _index.md
- components.md
- _index.md
- linux-commands.md
- _index.md
- hello-world.md
- index.md
content/docs/:知识库,每个子目录是一个分类,目录里的_index.md是分类首页。content/blog/:博客,按日期倒序排列。content/about/:独立页面。
新增内容
新建文件
在站点根目录执行(会套用 archetypes/ 里的模板):
# 知识库文章
hugo new content docs/notes/my-note.md
# 新的知识库分类
hugo new content docs/linux/_index.md
# 博客文章
hugo new content blog/my-post.md也可以直接手动创建 .md 文件。
编辑头部信息
每篇文章顶部的 front matter:
---
title: 文章标题
date: 2026-11-09
weight: 10 # 知识库中的排序,越小越靠前
draft: false # true 时只在本地预览中显示,正式构建不会发布
tags: [Linux, 运维]
---预览与发布
hugo server -D --bind 0.0.0.0 # 本地预览(含草稿),默认端口 1313
hugo --minify # 生成静态文件到 public/常用设置
| 想要 | 怎么做 |
|---|---|
| 调整侧边栏顺序 | front matter 里设 weight |
| 侧边栏显示短标题 | front matter 里设 linkTitle |
| 隐藏右侧目录 | toc: false |
| 不被搜索收录 | excludeSearch: true |
| 分类默认折叠 | 在分类 _index.md 里设 sidebar: { open: false } |
| 修改站名、菜单 | 编辑根目录 hugo.yaml |