Hugo安裝
Step1. install hugo
install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
then install hugo
brew install hugo
Step2. start a hugo project
make your project folder
hugo new site your_blog
cd your_blog
Step3. add theme
you can find more themes here
mkdir themes
# use git clone
git clone https://github.com/josephhutch/aether.git themes/aether
# use git submodule(recommend)
git submodule add https://github.com/josephhutch/aether.git themes/aether
enable theme
vim config.toml
# add new line
theme = "aether"
Step4. add post
hugo new posts/first-post.md
change draft: true
then run hugo server -w
for local test
Step5. publish to github
Because this is my personal website, so I use User/Organization Pages
-
create
{your-project}
repo on your github -
create
{username}.github.io
repo on your github -
add github page to submodule
git submodule add -b master [email protected]:{username}/{username}.github.io.git public
(you can use https as git url too) -
add shell to project folder, named
deploy.sh
#!/bin/bash echo -e "\033[0;32mDeploying updates to GitHub...\033[0m" # Build the project. hugo # if using a theme, replace with `hugo -t <YOURTHEME>` # Go To Public folder cd public # Add changes to git. git checkout master git add . # Commit changes. git commit -m "rebuilding site `date`" # Push source and build repos. git push origin master # Come Back up to the Project Root cd .. msg="updated at `date`" if [ $# -eq 1 ] then msg="$1" fi git add . git commit -m "$msg" git push origin master
-
run
git commit -am "yout website-hugo commit message "
thengit push origin master
-
deploy to
{yourname}.github.io
with./deploy.sh "your commit message"
Reference
發佈時間
2018-12-19