安装Hugo

Windows用户推荐下载预构建的二进制版本

比如解压到D:\hugo,然后将目录添加到PATH环境变量中

Mac 用户如果已经安装 HomeBrew 工具,一行命令即可完成

brew install hugo

新建站点

进入指定目录新建blog,并将站点配置文件改为.yml后缀写法(官方推荐):

hugo new site blog -f yml

添加主题

进入Hugo的官方主题网站 ,选择自己喜欢的主题。这里以PaperMod 主题为例演示,该主题提供三种安装方法 ,此处采用方法二安装: 进入网站的根目录,也就是blog文件夹所在路径执行

git submodule add --depth=1 https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod
git submodule update --init --recursive # needed when you reclone your repo

使用该主题,在配置文件里输入主题的名字

theme: PaperMod

新建文章

创建一个hello-world页面:

hugo new posts/hello-world.md

启动博客

在站点根目录下执行命令

hugo server -D

至此,一个基本的博客搭建完毕。