Hugo Site Deployment

#Programming #Blog #Webauthoring #Hugo #Git

Table of contents

  1. Workflow
  2. Makefile
Texteditor, terminal and browser

When I started publishing the blog I was using the git subtree approach, as suggested in the hugo documentation. However, I tend to mess up my setup when I amend or rebase when working with the local site.

Since I like to keep things simple, I have switched to keeping the generated site in a separate git repo, which I deploy by manually pushing to github pages.

The benefit of this is that I get to review the changes manually before deploying to the live site.

Workflow

Here is the basic outline of my workflow.

  1. create and edit some content
  2. review changes by serving up the site locally
  3. make as many commits as desired in the site hugo sources
  4. build the site for deployment
  5. review changes to the deployment git repo. I deliberately want to keep this step manual, since I am using the latest sources for hugo, and sometimes bugs causes weird things to happen to the ouput.
  6. push deployment repo to github

Makefile

The workflow may seem a little complicated, so I am using a Makefile I have created to avoid having to remember all the commands to type (or mistype, and screw up my site).

DEPLOYMENT_REPO=stou.github.io

all: server

build: dist

help:
	@echo "\033[0;4mAvailable targets:\033[0m"
	@echo " server - serves up site locally (default target)"
	@echo " build - build the content for deployment in ${DEPLOYMENT_REPO}"

view:
	# open front page in browser
	open http://localhost:1313

server: clean
	# Server the site up locally
	hugo server -w  --buildDrafts=true

clean:
	# clean out the local server build artifacts
	-rm -r public/*

dist: dist-clean
	# Build the project for publishing
	hugo -s . -d ${DEPLOYMENT_REPO}

dist-clean:
	# clean publishing output dir
	# NB: Avoid removing the .git folder
	-rm -r ${DEPLOYMENT_REPO}/*

This allows me to serve up the site locally simply by running make.

To build the site for deployment I run make build.

For the git operations, use whatever tool you are most familiar with. I personally like a combination of the command line and gitx, since I am using the Mac.

Flowers

Koh Lanta SUP Review

Rejseberetning fra Thailand. SUP på Klong Dao Beach, Koh Lanta

Cover image for post: Tour de Lanta

Tour de Lanta

Rejseberetning fra Ko Lanta i Thailand. Swimmingpool, elefanter, regnvejr og beach volley.

Latest posts

Zip Lines og Reggae

Rejseberetning fra Costa Rica

#Travel #Costa Rica

Hjemmefra havde vi blandt andet solgt turen til Costa Rica til drengene ved, at fortælle, at der skulle være nogle ret seje svævebaner man kunne prøve. Det er i Monteverde, at det virkeligt spiller - det der med svævebaner. Derfor var det næste stop på turen.

Brøleaber

Rejseberetning fra Costa Rica

#Travel #Costa Rica

Efter en del dage i surfparadis var selv vi, klar til at komme ud og se lidt mere af Costa Rica. I første omgang var vi blevet enige om, at køre videre til Nosara. Det ligger ca. 100 km op af kysten fra Santa Teresa. Det ville være muligt, at køre derop ad kystvejen men det kræver, at man krydser et par floder. Da det ikke på forhånd var til at sige, om det var tørt nok til, at krydse floderne, besluttede vi - dvs. Helene bestemte det - at køre den sikre tur på små 200 km udenom.

Surf Eat Sleep Repeat

Rejseberetning fra Costa Rica

#Travel #Costa Rica

Nu er vi kommet til Nosara, hvor vi praktisk talt har en ranch lidt oppe af en bjergskråning for os selv. Det vil sige, at vi har lejet et af værelserne, men da det er lavsæson nu, er vi de eneste gæster. Her er både swimming pool, havudsigt og en irsk pub. De sidste par uger, inden vi kom hertil, er gået med surf leg på Playa Hermosa.

Surf-sponsor-løb

Rejseberetning fra Costa Rica

#Travel #Costa Rica #Surf

Det at vi ikke var i Danmark eller havde cykler til rådighed skulle ikke forhindre drengene i at give deres bidrag til indsamlingen af penge til en ny legeplads på skolen. Som en alternativ løsning fandt vi på et andet koncept til indsamling af penge fra sponsorer.