7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

HugoをWerckerでビルドし、GitHub Pagesで公開するまでの手順

Last updated at Posted at 2015-04-21

preview: http://syui.github.io/lanyon-hugo/

repository: https://github.com/tummychow/lanyon-hugo

$ sudo pacman -S mercurial go

$ cat < EOF >> ~/.zshrc
if [ -x "`which go`" ]; then
  export GOPATH=\$HOME/go
  export PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin
fi
EOF

$ go get -v github.com/spf13/hugo

$ git clone https://github.com/tummychow/lanyon-hugo

$ cd lanyon-hugo

$ vim config.json
{
    "contentdir": "content",
    "layoutdir": "layouts",
    "publishdir": "public",

    "builddrafts": false,

    "baseurl": "http://syui.github.io/lanyon-hugo/",
    "canonifyurls": true,
    "permalinks": {
        "post": ":year/:month/:day/:title/",
        "fixed": ":title/"
    },

    "params": {
        "Title": "Lanyon",
        "Tagline": "A Jekyll theme",
        "Author": "Mark Otto",
        "DateForm": "Jan 2 2006",
        "Github": {
            "Url": "http://github.com/syui/lanyon-hugo",
            "Head": "master"
        }
    }
}

$ hugo server
$ firefox localhost:1313/lanyon-hugo

$ git add .

$ git commit -m "force"

# forceしたものを自分のリポジトリに上げます
$ git push

$ hugo

$ git push --delete origin gh-pages

$ cp -rf .git public/

$ cd public
$ jekyll server

$ git checkout -b gh-pages

$ git add .

$ git commit -m "up"

$ git push -f origin gh-pages

$ cd ..

$ cat < EOF > wercker.yml
box: wercker/default
build:
  steps:
    - arjen/hugo-build:
        version: 0.12
        theme: herring-cove
        flags: --buildDrafts=true

deploy:
    steps:
        - lukevivier/gh-pages:
            token: \$GITHUB_TOKEN
            basedir: ./public
            repo: syui/lanyon-hugo
EOF

$ git add wercker.yml

$ git commit -m "ci"

$ git push

テンプレートが古いので、更新スクリプトを書きました。基本的には、wordに変更するワードを入れれば、自動で書き換えます。

# !/bin/bash

# ERROR: 2015/04/22 Node's .Url is deprecated and will be removed in Hugo 0.15. Use .URL instead.
# ERROR: 2015/04/22 Site's .Recent is deprecated and will be removed in Hugo 0.15. Use .Pages instead.

word1=".Url"
word2=".URL"

grep -R $word1 ../  |grep -v config.json | grep -v hugo-1.5-url-fix.sh

echo [y]
read key
case $key in
    y)
        file=`grep -r $word1 ../ | cut -d : -f-1 | grep -v config.json | grep -v hugo-1.5-url-fix.sh`
        echo "$file"
        for (( i=1;i<=`echo "$file" | wc -l | tr -d ' '`;i++ ))
        do
            a=`echo "$file" | awk "NR==$i"`
            echo $a
            case $OSTYPE in
                darwin*)
                    com="s/${word1}/${word2}/g"
                    sed -i "" ${com} $a
                    ;;
                linux*)
                    com="s/${word1}/${word2}/g"
                    sed -i ${com} $a
                    ;;
            esac
        done
        ;;
esac

あとは、werckerにログインして、アプリを設定します。

WerckerでMiddlemanのBuild,Deployを自動化する

OctopressをBitbucketで管理し、Werckerでデプロイする方法

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?