如何搭建 hugo 博客

以我的 github hugo 博客为例,讲解如何搭建 hugo 博客


  1. 下载 hugo 客户端,添加 PATH

  2. 新建一个文件夹,用 cmder 打开,运行
    hugo new site zen-yang.github.io-creator

  3. 用 VSCode 打开 zen-yang.github.io-creator 文件夹,新开一个终端,运行

  git init
  git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke
  echo 'theme = "ananke"' >> config.toml
  hugo new posts/你的博客名字.md
  1. 打开 content/posts 文件夹下的 你的博客名字.md 文件

  2. 写博客内容,最后修改 draft 为 false(draft 为草稿的意思)

  3. 终端 运行 hugo server -D

  4. 修改 config.toml
    将 languageCode 改为 zh-Hans
    将 title 改为你自己博客的 title

  5. 再新开一个终端,运行命令 hugo,然后 cd public

  6. 新建 .gitignore 文件
    写上 /public/

  7. 终端中,进入了 public 文件夹后,

git init
git add .
git commit -v
// commit 详情中写 第一次部署,关闭详情文件
  1. 自己的 github 创建 zen-yang.github.io 项目
 git remote add origin git@github.com:zen-yang/zen-yang.github.io.git
 git push -u origin master

在 VSCode 终端运行这两行代码

  1. 去到 zen-yang.github.io 项目,Settings
    往下拉,看到 GitHub Pages,选择 source为 master,点击 https://zen-yang.github.io/
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容