Hugo搭建个人博客

本文最后更新于:2022年8月8日 晚上

🎟️开始

0.安装ChocolateyScoop

以下以Chocolatey为例,Scoop与之相似,可参阅官方文档

安装后打开终端,输入

1
$ choco --version

检查安装是否成功

1.安装Hugo

输入

1
$ choco install hugo -confirm    #普通版本

1
$ choco install hugo-extended -confirm    #带有Sass/SCSS的扩展版本

2.创建站点

输入

1
$ hugo new site quickstart

就会在quickstart目录下创建Hugo站点

3.添加主题

此处以Kagome为例,其他主题

依次执行以下三行

1
2
3
$ cd quickstart
$ git init
$ git submodule add https://github.com/miiiku/hugo-theme-kagome.git ./themes/kagome #此处的链接可根据需求替换

然后更改配置文件

1
$ echo theme = \"ananke\" >> config.toml

4.写下第一篇文章

1
$ hugo new posts/my-first-post.md

文章会带一个Format Matter

1
2
3
4
5
---
title: "My First Post"
date: 2022-08-08T20:00:11+08:00
draft: true
---

当要发布文章时,将draft: true 改为false即可

5.本地预览

1
$ hugo server -D

打开http://localhost:1313查看效果

6.主题配置

config.toml中编辑即可

🪁部署

初始化

执行hugo -D生成./public文件夹后,依次执行以下指令

1
2
$ cd ~/quickstart/public  # 生成的 HTML 文件保存在 "public" 目录中,"public" 文件夹会被转换为 Git 库。 
$ git init # 初始化 Git 库。

添加远程库

1
$ git remote add origin git@github.com:<YOURNAME>/<YOURNAME>.github.io.git

提交更改

1
2
3
$ git status  # 查看当前修改状态。
$ git add . # 添加所有修改过的文件。你也可以只添加某个文件。
$ git commit -m "Add a new post" # commit message.

推送

1
$ git push -u origin main

完结撒花🎉

✨进阶


Hugo搭建个人博客
https://qwerx29.github.io/posts/3bc0bbc9.html
发布于
2022年8月8日
更新于
2022年8月8日
许可协议