环境准备#
- 设备:ubuntu
- github地址:https://github.com/gohugoio/hugo
- 安装:
</>
shell
1wget https://github.com/gohugoio/hugo/releases/download/v0.147.9/hugo_extended_0.147.9_Linux-64bit.tar.gz
2tar -xvzf hugo_extended_0.147.9_Linux-64bit.tar.gz
3sudo su
4mv hugo /usr/binStart!#
1. 基础#
1. 创建新博客#
</>
shell
1hugo new site siteproducer2. 重要配置&配置逻辑链#
2. 使用stack主题#
</>
shell
1git submodule add https://github.com/CaiJimmy/hugo-theme-stack themes/hugo-theme-stackHugo Tricks#
1. 自定义样式#
1. 样式覆盖规则:后引入覆盖前引入#
- params.yaml配置中指定自定义custom_css
</>
yaml
1custom_css: ["scss/custom.scss"]- assets/custom.scss中
</>
scss
1// 引入主题样式
2@import "general";
3// 引入你的自定义覆盖
4@import "custom-markdown"; // 无下划线、无扩展名2. 自定义鸿蒙字体#
- 下载鸿蒙字体
- 解压到siteproducer/assets/fonts目录
- 在assets/scss/中创建_fonts.scss,并在scss/custom.scss中引用
font.scss
</>
scss
1@font-face {
2 font-family: 'HarmonyOS_Sans_SC_Medium';
3 font-style: normal;
4 font-display: swap;
5 src: url('{{ (resources.Get "fonts/HarmonyOS_Sans_SC_Medium.woff2").RelPermalink }}') format('woff2');
6}
7@font-face {
8 font-family: 'JetBrainsMono Regular';
9 font-style: normal;
10 font-display: swap;
11 src: url('{{ (resources.Get "fonts/JetBrainsMono-Regular.woff2").RelPermalink }}') format('woff2');
12}
13
14:root {
15 --font-sans: 'HarmonyOS_Sans_SC_Medium', system-ui, -apple-system, sans-serif;
16 --font-mono: 'JetBrainsMono Regular', monospace;
17}
18body {
19 font-family: var(--font-sans);
20 line-height: 1.6;
21 color: #333;
22}
23
24code, pre {
25 font-family: var(--font-mono);
26}custom.scss
</>
scss
1@import "fonts";3. blowfish theme 打开默认文档大纲#
- md Front Matter中设置对应toc变量,不同主题可能使用不同Front Matter变量
</>
yaml
1# bluefish 使用showTableOfContents
2showTableOfContents: true
3# 默认使用toc
4toc: true- params.yaml中设置
</>
yaml
1smartTOC: true2. 分级目录#
- 主题默认支持分级目录,但子目录不一定有独立样式,需要每一层子目录中创建
_index.md
</>
markdown
1---
2title: "title"
3description: "desc"
4---- 使用deepseek自定义list.html覆盖主题提供的样式
todo#
分级目录、tag云图markdown代码块左上角显示代码语言,右上角复制按钮文档大纲-done- 文档字数正确记数
markdown 代码块渲染- 文章标签
- markdown代码块功能优化
- 取消单独折叠按钮
- </> 区
- 增加折叠功能
- 增加悬浮伸缩动画效果
- 代码语言(hint)中文独立样式,支持markdown渲染
- 自动换行按钮
- tag筛选搜索器