使用Hugo搭建博客

163 阅读1分钟

以下均以MacOS系统为例

1.安装Hugo

brew install hugo

检查安装成功与否:hugo version


2.创建网站文件夹

hugo new site custom_site_name

3.添加主题

cd custom_site_name
git init
git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke
echo 'theme = "ananke"' >> config.toml

4.写博客

hugo new posts/my-first-post.md
vi new posts/my-first-post.md

5.博客预览

hugo server -D

6.部署到GitHub Pages

  • 新建仓库username.github.io

  • 进入Hugo网站根目录

  • cd public
    git init
    git remote add origin git@github.com:username/username.github.io.git
    git add .
    git commit -m custom_commit_message
    git push -u origin master
    
  • 如果需要独立域名,新建CNAME文件并在里面填写主域名