@QuantumGhost@haobug 的大力推动下,换用了 Hugo 作为 CDLUG 站点的生成系统,各项内容逐步完善中。这里主要介绍 Hugo 的一些基本使用,还有如何协作更新、发表文章。

增加新文章流程

这里列出大概流程,具体操作见后面说明

  1. 初次使用,需要先 fork 到自己的 GitHub 仓库,然后克隆该仓库到本地
  2. 使用 hugo 指令创建 .md 文件
  3. 本地测试预览
  4. 提交修改,push 到 GitHub 你的仓库
  5. 发起到 CDLUG 仓库的 pull request
  6. Review 之后,merge 到 master,Netlify 会检测到新的版本,自动更新 cdlug.org

Hugo 的基本使用

这里只列出基本的几个操作,更多使用详见Hugo中文文档

  1. Clone 仓库,注意有 submodule

    $ git clone --recursive <project url>
    
  2. 创建新文章

    $ hugo new post/some-content.md
    
  3. 运行预览(使用 even 主题)

    $ hugo server -D 
    

    关于 even 主题的一些坑

文章的格式和建议

Front Matter 数据设置

建议参考 even 主题的文档Hugo 文档 Front Matter

在仓库内 archetypes 目录里有两个文件会在 hugo new 的时候使用到,其中

  • archetypes/default.md 是默认会使用的文件
  • archetypes/even_default_mod.md 是根据 even 主题提供的默认模版的修改,可以作参考用

GitHub 协作

  • Clone 仓库
    $ git clone --recursive <project url>
    
  • Review PR
     $ git remote add cdlug https://github.com/cdlug/cdlug.github.io/
     $ git remote update cdlug
     $ git fetch cdlug pull/38/head:localTest
     $ git checkout localTest
    

参考资料