新的探索!——从 Hexo 到 Hugo

听闻 Hugo 生成静态网页的速度比 Hexo 快许多,遂进行尝试。

安装 Hugo 扩展版

1
2
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
choco install hugo-extended

本地建立站点并克隆主题

1
2
3
hugo new site blog3
cd blog3
git clone https://github.com/HEIGE-PCloud/DoIt.git themes/DoIt

站点配置文件添加配置

1
theme = "DoIt"

本地生成博客内容

1
hugo server --disableFastRender -e production

访问localhost:1313即可

发布博客到互联网

把博客资源 push 到 GitHub 仓库,再用 Vercel 托管即可

初次操作

创建一个 GitHub 仓库,之后在本地博客根目录执行如下命令

1
2
3
4
5
6
7
8
hugo
cd public
git init
git add .
git commit -m 'message'
git branch -M main
git remote add origin git@github.com:<username>/<reponame>.git
git push -u origin main

平时操作

1
2
3
4
5
hugo
cd public
git add .
git commit -m 'message'
git push