Skip to main content
  1. Posts/

Hugo

·184 words·1 min
Table of Contents

Hexo から Hugo
#

サイトジェネレータを Hugo に変えてみた。インストールといっても homebrew を使うので簡単 :grin:

EMOJI-CHEAT-SHEET

インストール
#

Homebrew はインストール済みという前提で進める。

$ brew update
$ brew install hugo

テーマは conao3さんanatole-ext にすることにした。

$ hugo new site hoge
$ cd hoge
$ git clone https://github.com/conao3/anatole-ext themes/anatole-ext
$ hugo new posts/first-article.md

これで hoge ディレクトリーが作成され、その配下に雛形が作成される。

自分用のメモ
#

展開
#

$ git clone [email protected]:ac1965/hugo.git ./hugo-blog
$ cd hugo-blog
$ git clone [email protected]:ac1965/anatole-ext themes/anatole-ext
$ hugo

hugo コマンドを実行すると、public ディレクトリの下にコンテンツが生成される。

`deploy.sh'
#

hexo と大きく違うのは、デプロイの仕組みが利用者まかせになっているところ。

私の環境では本体用と公開用でリポジトリを分けていて、本体は hugo-blog、公開用は ac1965.github.com として管理している。

deploy.sh
  #! /bin/bash

  hugo=~/devel/repos/hugo-blog
  public=~/devel/repos/ac1965.github.io

  abort ()
  {
      echo -e "\033[1;30m>\033[0;31m>\033[1;31m> ERROR:\033[0m${@}\n" && exit
  }

  info ()
  {
      echo -e "\033[1;30m>\033[0;36m>\033[1;36m> \033[0m${@}\n"
  }

  warn ()
  {
      echo -e "\033[1;30m>\033[0;33m>\033[1;33m> \033[0m${@}\n"
  }

  test -d ${hugo} && cd ${hugo} || abort "${hogo} directory not found."
  # clean public
  rm -fr public

  info "Deploying updates to GitHub..."

  # Build the project.
  hugo # if using a theme, replace with `hugo -t <YOURTHEME>`

  # Go To Public folder
  test -d ${public} && cd ${public} || exit
  info "rsync.."
  rsync -at --delete --exclude=".git" ${hugo}/public/. .

  # Add changes to git.
  git add .
  git commit -avm "update:$(env LANG=C date)" && git push

Related