使用HUGO搭建个人网站。

Requirements

Git

Go

  1. 安装golong版本管理工具

    bison --version    #测试是否已经安装
    brew install bison
    
    bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
    
  2. 使用gvm下载go:

    brew install go@1.22    #gvm需要先拥有一个go
    gvm install go1.23
    gvm use go1.23    #default
    

Dart Sass

使用 Sass 语言的最新功能时,需要 Dart Sass 将 Sass 转译为 CSS。

brew install sass/sass/sass

HUGO下载

extended/deploy editions:可以将您的网站直接部署到 Google Cloud Storage 存储桶、AWS S3 存储桶或 Azure 存储容器。查看详细信息

  1. Install a C compiler, either GCC or Clang 二选一

    gcc --version    #check gcc是否安装
    clang --version    #check clang是否安装
    
  2. To build the extended/deploy edition:

    CGO_ENABLED=1 go install -tags extended,withdeploy github.com/gohugoio/hugo@latest
    
    hugo version    #check
    

构建站点-本地

  1. 创建 Hugo 项目

    hugo new site --format yaml
    hugo new site /Users/sukixuu/Desktop/SukiBlog --format yaml   #指定路径
    
  2. 进入项目目录并添加主题

    cd /Users/sukixuu/Desktop/SukiBlog    #进入目录
    
    • Theme选择,根据文档安装;这里使用PaperMod
      git init
      
      下载:
      git submodule add --depth=1 https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod
      git submodule update --init --recursive # needed when you reclone your repo (submodules may not get cloned automatically)
      
      更新(以后更新使用):
      git submodule update --remote --merge
      
  3. 将网站配置中的主题设置为PaperMod 在 hugo.yaml 中添加以下,并重新命名成为 config.yaml

    theme: ["PaperMod"]
    
  4. 启动 Hugo 服务器

    hugo server