【网站搭建】Hugo 配置
记录第一次用 Hugo 搭静态站的流程。
前期准备 1)安装 Go 从 All releases - The Go Programming Language 下载 .msi 安装包,安装到选定目录。
在终端输入:
go version 能输出版本号就说明安装成功。
2)安装 Hugo 从 gohugoio/hugo Releases 下载 Hugo,把 hugo.exe 所在目录加入系统环境变量 Path。
验证:
hugo version 网站部署 1)创建一个新网站 hugo new site page-name 2)配置主题 在 Hugo Themes 里挑一个主题,然后在网站目录中执行:
cd page-name git init git submodule add <主题仓库地址> themes/<主题名> 用 VS Code 打开网站目录,在配置文件 hugo.toml(旧版本是 config.toml)中写入:
theme = "theme-name" 现在 Hugo 默认生成 hugo.toml;如果主题文档写的是 config.toml,两者作用相同,选一个即可。
3)添加内容 hugo new posts/post-name.md Markdown 语法可以看 Markdown 官方教程。