References:

Install Hugo and bootstrap site folder

First we need to install hugo with brew install hugo.

Then create the site/folder:

hugo new site blog
cd blog
git init

Choose a Theme and install it as git submodule

git submodule add https://github.com/panr/hugo-theme-hello-friend.git themes/hello-friend

Then do a first commit and push to a new empty repository on github

git add .
git commit -m"Initial commit"
git remote add origin https://github.com/tgarlot/blog.git
git push -u origin master

Create some content

Create some content (like a new post)

hugo new posts/new-post.md

Then add, commit and push the changes.

Publish

First create a new repository on Github that will content the generated HTML content of the site. It MUSt be named username.github.io

Generate site with hugo command. It will output files into the public folder. Initialise a Git repo and commit the generated files.

hugo
cd public
git init
git add .
git commit -m"Initial commit"

Add a remote to the Github repository and push.

git remote add origin https://github.com/tgarlot/tgarlot.github.io.git
git push -u origin master

Then add the public as a Git submodule:

cd ..
rm -rf public
git submodule add -b master https://github.com/tgarlot/tgarlot.github.io.git public
git add .
git commit -m"Add public folder as submodule"
git push -u origin master

Add or edit some content

  • update a markdown file
  • run hugo command to regenerate the content of the public folder
  • add/commit/push in BOTH repositoriy (public and content)