Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save snassr/68bea55528c7b2421fdb40c547da71d9 to your computer and use it in GitHub Desktop.
Save snassr/68bea55528c7b2421fdb40c547da71d9 to your computer and use it in GitHub Desktop.
Medium Blog - Build and Deploy a Hugo Blog With Caddy - Setup Development Environment
# download hugo
wget -O ~/Downloads/hugo_0.31.1_Linux-64bit.deb https://github.com/gohugoio/hugo/releases/download/v0.31.1/hugo_0.31.1_Linux-64bit.deb
# install hugo
sudo dpkg -i ~/Downloads/hugo_0.31.1_Linux-64bit.deb
# verify install
hugo version
# download & install caddy
curl https://getcaddy.com | bash -s personal http.git,http.minify
# verify install
caddy -version
# create a repository in github (initialize with README)
# export github repository name
export GITHUB_REPONAME=myblog
# export github username
export GITHUB_USERNAME=snassr
# export location for repository
export OS_REPOLOCATION=~/$GITHUB_REPONAME
# create directory for repo
mkdir -p $OS_REPOLOCATION
# clone github repo into location
git clone https://github.com/$GITHUB_USERNAME/$GITHUB_REPONAME $OS_REPOLOCATION
# change directory to repo
cd $OS_REPOLOCATION
# create a new site
hugo new site $GITHUB_REPONAME
# change directory to blog folder
cd $OS_REPOLOCATION/$GITHUB_REPONAME
# create first about
hugo new about.md
# enable about page (draft: false)
sed -i 's/draft: true/draft: false/g' content/about.md
# create first post
hugo new post/my-first-post.md
echo '# Hello World' >> content/post/my-first-post.md
# enable my-first-post page (draft: false)
sed -i 's/draft: true/draft: false/g' content/post/my-first-post.md
# view new posts under content
ll content/
# add a theme
git clone https://github.com/tanksuzuki/hemingway $OS_REPOLOCATION/$GITHUB_REPONAME/themes/hemingway
echo 'theme = "hemingway"' >> config.toml
# remove .git file so that we keep all files (see git submodules to better handle this)
rm -rf $OS_REPOLOCATION/$GITHUB_REPONAME/themes/hemingway/.git
# start server
hugo server
# view in broswer on localhost:hugoAssignedPortFromAboveCommand
# commit
echo 'public/' > .gitignore
git add --all
git commit -m "Setup Development Environment - completed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment