Hugo搭建个人博客

286 阅读1分钟

下载Hugo

首先下载Hugo软件 github.com/gohugoio/hu…

然后解压,将解压后的路径添加到Path

设置Hugo

进入官网,找到设置代码 gohugo.io/getting-sta…

  1. 确认Hugo版本,hugo version
  2. 新建Hugo站点,文件夹名为Captain-Tab.github.io-creator
hugo new site Captain-Tab.github.io-creator // 创建命令
  1. 进入文件夹,并下载主题
cd Captain-Tab.github.io-creator
git init
git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke
  1. 添加主题到配置文件

echo 'theme = "ananke"' >> config.toml

  1. 添加博客目录,名为开博大吉

hugo new posts/开博大吉.md

  1. 运行本地Hugo服务器

hugo server -D

  1. 设置主题和标题
baseURL = "https://example.org/"
languageCode = "en-us"
title = "My New Hugo Site"
theme = "ananke"
  1. 生成静态页面

hugo -D

关联GitHub 仓库

  1. GitHub页面新建一个远程仓库,名为Captain-Tab.github.io-creator
  2. 然后新建本地仓库,在Captain-Tab.github.io-creator文件夹中,代码为
cd public
git init
git add .
git commit -v hello
  1. 接着关联远程仓库
git remote add origin git@github.com:xxxx/x.github.io.git
push -u origin master
  1. 最后在GitHub的仓库设置界面,找到GitHub pages,进行浏览

购买域名,配置DNS

  1. 首先购买域名,推荐namesilo
  2. 然后添加四条A记录
  3. 检查是否正常 nslookup + 域名
  4. 最后添加域名,配置GitHub Page