Hugo 安装与使用
Hugo 安装与使用,个人笔记、技术文档的静态站点,Gitee、Github可免费托管。
参考文档
https://gohugo.io/documentation/
安装Git
https://git-scm.com/book/zh/v2
https://git-scm.com/download/win
安装tree命令工具
下载解压后的bin目录下找到tree.exe
把tree.exe拷贝到GitBash安装路径的usr\bin目录下
https://gnuwin32.sourceforge.net/packages/tree.htm
https://renlm.gitee.io/download/git/tree-1.5.2.2-bin.tar.gz
# 压缩文件
tar -zcvf dist.tar.gz dist
# 解压文件
tar -zxvf dist.tar.gz dist
安装Go
下载并安装
https://go.dev/dl/
https://dl.google.com/go/go1.18.8.windows-386.zip
环境变量
GOROOT:Go 语言安装根目录的路径,也就是 GO 语言的安装路径。
GOPATH:若干工作区目录的路径,是我们自己定义的工作空间。
GOBIN:GO 程序生成的可执行文件(executable file)的路径。
变量配置
$ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cn,direct
常见命令
# 查看版本
$ go version
# 查看环境变量
$ go env
安装Hugo
下载extended版本,解压后把hugo.exe放入GOBIN目录下
https://github.com/gohugoio/hugo/releases
hugo version
Hugo的使用
建立站点
hugo new site blogs
$ cd blogs
$ tree
.
`-- blogs
|-- archetypes
| `-- default.md
|-- config.toml
|-- content
|-- data
|-- layouts
|-- public
|-- static
`-- themes
8 directories, 2 files
使用主题
$ git submodule add https://gitee.com/hugo-next/hugo-theme-next.git themes/hugo-theme-next
$ cp themes/hugo-theme-next/exampleSite/config.yaml .
$ mv config.toml config.toml.backup
主题更新
git submodule update --remote
创建文件
hugo new post/first.md
本地演示
hugo server -D
部署
hugo
会生成public,public的内容直接部署到服务器上即可