一 博客配置

  1. 安装引擎:Hugo

  2. 选择主题:Even

  3. 关联 GitHub

    运行命令hugo -t even

    Hugo将编译所有文件并输出到public目录,你需要在github上创建repository,名字就是<你的用户名>.github.io,创建完后,返回你本地命令行,进入public目录,执行以下命令:

    1
    2
    3
    4
    5
    
    git init
    git add .
    git commit -m "Initial commit."
    git remote add origin ...
    git push -u origin master

    稍等片刻后,打开<你的用户名>.github.io网址,就可以看到你的个人网站了。

  4. 博客更新脚本deploy.sh,位于站点目录下。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
    #!/bin/bash
           
    echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
           
    # Build the project.
    hugo -t even # if using a theme, replace with `hugo -t <YOURTHEME>`
           
    # Go To Public folder
    cd public
    # Add changes to git.
    git add .
           
    # Commit changes.
    msg="rebuilding site `date`"
    if [ $# -eq 1 ]
      then msg="$1"
    fi
    git commit -m "$msg"
        
    # Push source and build repos.
    git push origin master
        
    # Come Back up to the Project Root
    cd ..
  5. 添加评论

二 博客使用

  1. 说明
    • draft 设置为false的时候会被编译为HTML,true则不会编译和发表,在本地修改文章时候用true。