Setup Blog with Hugo with Github Pages
Github에서 제공하는 Pages기능을 이용해서, 블로그를 무료(??)로 이용하는 방법에 대해서 설명합니다.
최초 설치
github.com에서 컨텐츠를 생성할 계정을 생성합니다.public Repository를 생성합니다.반드시
계정명.github.io의 Repository 이름으로 생성해야 합니다.HUGO Server를 설치한 후, config.toml파일을 설정합니다.
baseurl = "http://xenostream.github.io/"
languageCode = "en-us"
title = "XenoStream's Private Site"
theme = "vienna"
copyright = "©Xenostream.com. ®2016 All Rights Reserved."
contentdir = "content"
layoutdir = "layouts"
publishdir = "public"
builddrafts = "false"
canonifyurls = "true"
datadir = "data"
hasCJKLanguage = "true"
paginate = "5"
[permalinks]
post = "/:year/:month/:title"
[taxonomies]
category = "categories"
tag = "tags"
[params]
# github = "xenostream"
# googleplus = "xenostream"
disqus = "xenostream"
subtitle = "Software & System Engineer!!"
tags = "/tags"
about = "/2016/02/about"
archive = "/post"
Post 생성
/root/Hugo/xenostream디렉토리의contents/post디렉토리에서 새로운 포스트를 생성합니다.또는
hugo new /post/test.md명령으로 자동생성해도 됩니다.hugo명령어를 실행해서 새로운 포스트의 정적 파일을 자동생성 합니다. (public 디렉토리 생성됨)새롭게 생성된
public디렉토리에서 다음의 명령으로 동기화 합니다.
cd public
git init
git remote add origin https://github.com/xenostream/xenostream.github.io.git
git add .
git commit -m "Init: 2017/01/04"
git push -u origin master
10분정도의 Delay후에 해당 페이지가 갱신됩니다.(곧바로 되는 경우도 있습니다)
포스트 추가
추가적인 포스트를 작성한 후에 추가분만 동기화 할 경우에는 다음과 같이 진행합니다.
cd /root/Hugo/xenostream
vi contents/post/test.md
hugo
cd public
git add .
git commit -m "변경사유"
git push origin master
자동배포 스크립트
/root/Hugo/xenostream 디렉토리에서 사용
#!/bin/bash
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
# Build the project.
hugo # if using a theme, replace by `hugo -t <yourtheme>`
# Go To Public folder
cd public
# Add changes to git.
git add -A
# 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
cd ..