Hugo Toha 项目教程
1. 项目的目录结构及介绍
hugo-toha.github.io/
├── archetypes/
│ └── default.md
├── assets/
│ ├── css/
│ ├── js/
│ └── images/
├── content/
│ ├── about/
│ ├── blog/
│ ├── projects/
│ └── resume/
├── data/
│ └── config.yaml
├── static/
│ ├── favicon.ico
│ └── robots.txt
├── .gitignore
├── .gitlab-ci.yml
├── hugo_build.lock
├── LICENSE
├── README.md
├── go.mod
├── go.sum
├── hugo.yaml
├── netlify.toml
├── package-lock.json
├── package.hugo.json
└── package.json
目录结构介绍
- archetypes/: 包含默认的内容模板文件
default.md
。 - assets/: 存放项目的静态资源,如 CSS、JavaScript 和图片。
- content/: 存放网站的内容文件,包括关于页面、博客文章、项目和简历。
- data/: 存放项目的配置文件
config.yaml
。 - static/: 存放静态文件,如网站图标和 robots.txt。
- .gitignore: Git 忽略文件列表。
- .gitlab-ci.yml: GitLab CI/CD 配置文件。
- hugo_build.lock: Hugo 构建锁文件。
- LICENSE: 项目许可证文件。
- README.md: 项目说明文件。
- go.mod: Go 模块依赖文件。
- go.sum: Go 模块校验文件。
- hugo.yaml: Hugo 配置文件。
- netlify.toml: Netlify 配置文件。
- package-lock.json: npm 锁定文件。
- package.hugo.json: Hugo 包配置文件。
- package.json: npm 包配置文件。
2. 项目的启动文件介绍
启动命令
hugo server -w
命令介绍
- hugo server: 启动 Hugo 开发服务器。
- -w: 监听文件变化并自动重新加载。
3. 项目的配置文件介绍
hugo.yaml
baseURL: "https://hugo-toha.github.io/"
languageCode: "en-us"
title: "Hugo Toha"
theme: "toha"
配置文件介绍
- baseURL: 网站的基础 URL。
- languageCode: 网站的语言代码。
- title: 网站的标题。
- theme: 使用的 Hugo 主题,这里是
toha
。
netlify.toml
[build]
publish = "public"
command = "hugo --gc --minify"
[context.production.environment]
HUGO_VERSION = "0.88.1"
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"
配置文件介绍
- publish: 发布目录,这里是
public
。 - command: 构建命令,使用
hugo --gc --minify
。 - HUGO_VERSION: Hugo 版本。
- HUGO_ENV: 环境变量,这里是
production
。 - HUGO_ENABLEGITINFO: 启用 Git 信息。
通过以上配置,您可以轻松启动并配置 Hugo Toha 项目。