沙滩星空的博客沙滩星空的博客

使用Hugo创建Github Pages博客或文档

创建Git仓库

Github上创建仓库,仓库名为 username.github.io, 其中 username 必须为实际GitHub账号的用户名。

安装hugo

很多主题需要 扩展版 的hugo才能安装。故应安装 扩展版的hugo.

安装方法有二: 1. 直接下载 Releases 发布包. 2. 通过 go install 命令安装

  1. 下载hugo发布包(文件名含extended): https://github.com/gohugoio/hugo/releases
  2. Go 安装: go env -w CGO_ENABLED=1, go install --tags extended github.com/gohugoio/hugo@latest

验证安装:

hugo version
hugo v0.106.0-e08ce30fe4779e7d8a8395d7021314b915648cb4+extended windows/amd64 BuildDate=2022-11-17T18:33:40Z VendorInfo=gohugoio

在 Windows 环境下编译 扩展版 的 Hugo, 还需要安装 GCC编译器, 请看说明文档

创建博客

# 1. Create a New Site
hugo new site quickstart
# 2. Add a Theme
cd quickstart
git init
git submodule add https://github.com/leafee98/hugo-theme-flat themes/hugo-theme-flat
echo theme = \"hugo-theme-flat\" >> config.toml
# 3. Add Some Content
hugo new posts/my-first-post.md
# 4. Start the Hugo server
hugo server -D
# 5. Site Configuration
vim config.toml
# 6. Build static pages
hugo -D

配置

# config.toml
title = "我的博客"
theme="hugo-theme-flat"

module主题

有些主题为 Hugo module,必须额外配置:
在项目跟目录运行: hugo mod init 项目名(博客名)
在配置文件 config.toml 添加模块配置项

# config.toml
[[module.imports]]
path = "github.com/CaiJimmy/hugo-theme-stack/v3"

https://stack.jimmycai.com/guide/getting-started


https://pages.github.com/
https://gohugo.io/getting-started/quick-start/
Hugo Config https://ithelp.ithome.com.tw/articles/10241051

未经允许不得转载:沙滩星空的博客 » 使用Hugo创建Github Pages博客或文档

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址