Skip to content

Instantly share code, notes, and snippets.

@mgei
Last active May 6, 2019 15:26
Show Gist options
  • Save mgei/c6f31cecf45c7b4d58567dffbe95ed31 to your computer and use it in GitHub Desktop.
Save mgei/c6f31cecf45c7b4d58567dffbe95ed31 to your computer and use it in GitHub Desktop.
# to install the latest version 0.53 of Hugo on Ubuntu:
# releases are here: https://github.com/gohugoio/hugo/releases
export VER="0.55.5"
wget https://github.com/gohugoio/hugo/releases/download/v0.55.5/hugo_${VER}_Linux-64bit.deb
sudo dpkg -i hugo_${VER}_Linux-64bit.deb
# check if right version is installed
hugo version
# make a new website (don't do that if you already have one)
# first go to the directory where a new folder for your website should be made
cd ~/Documents/websites/
# new site
hugo site new "mywebsite"
# add a theme to a new or existing website
# 1. go choose a theme here: https://themes.gohugo.io/
# see on Github that the last commit is not too long ago (<12mths), so you know it's maintained
# also make sure the theme comes with an exampleSite
cd mywebsite/themes
git clone <the git repository of the theme you just selected>
# to use the example site, move the exampleSite contains to the root directory of your website
mv -r mywebsite/themes/YOURTHEME/exampleSite/. mywebsite/.
# to edit, in general most content is in the content folder (in the root directory, not somewhere in themes)
# static files such as images can be put in static directory
# most contents is in Markdown .md and config files for most themes are in YAML or TOML
# preview the site
hugo server
# base URL: in config.toml (or .yaml) in the root dir, change baseURL
# then making your real website, specify it as https://YOURGITHUBHANDLE.github.io
# when you preview, you want to edit something but you don't know where, them search for it
cd content
grep -r "whatever you are looking for"
# then you know which file have a closer look and to edit to make the desired changes
# deploy the website on github
# 1. go on github and create a new repo called YOURGITHUBNAME.github.io
# 2. copy the url .git that it gives you
# on your computer in the yourwebsite directory
git init
git add .
git commit -m "initial commit"
git remote add origin remote repository URL
git push
# you will be promted your login details
# deploy:
# but first build it properly (not just preview version with relative URLs)
hugo
# Go To Public folder
cd public
# Add changes to git.
git add .
# Commit changes.
git commit -m "site update"
# Push source and build repos.
git push origin master
# this "deploy" can also be put in a bash deploy.sh so each time you make a change you can just bash deploy.sh and it updates your github site
# the site should be accessible over https://YOURNAME.github.io
# might take a minute or so
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment