Below you will find pages that utilize the taxonomy term “个人博客”
April 18, 2025
部署个人博客:Hugo + GitHub Pages
🚀 一、安装 Hugo
首先,使用 winget
在 Windows 上安装 Hugo:
winget install Hugo.Hugo.Extended
安装完成后,验证是否成功安装 Hugo:
hugo version
如果命令行中显示版本信息,说明安装成功。
🏗️ 二、创建 Hugo 网站
接下来,创建一个新的 Hugo 网站:
hugo new site my-blog
进入站点目录:
cd my-blog
🎨 三、安装主题
您可以访问 Hugo Themes 选择喜欢的主题,或者使用以下命令直接安装 ananke
主题:
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
然后,在 config.toml
文件中设置主题:
theme = "ananke"
✍️ 四、创建文章
您可以通过以下命令创建一篇新的文章:
hugo new posts/my-first-post.md
在 content/posts/my-first-post.md
文件中,使用 Markdown 编辑您的文章内容。
🌐 五、预览本地站点
通过启动本地服务器,您可以在浏览器中查看站点效果:
hugo server -D
在浏览器中访问 http://localhost:1313/
进行预览。
📦 六、部署到 GitHub Pages
1. 创建 GitHub 仓库
在 GitHub 上创建一个新的仓库,并命名为 username.github.io
,这是 GitHub Pages 的标准仓库命名方式。