Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shell script that will switch to your blog directory, start a testing Hugo server, wait for it to begin, and then connect it to the Internet via a free Cloudflare Argo Tunnel.
#!/bin/bash
trap "exit" INT TERM ERR
trap "kill 0" EXIT
# These lines make sure that the Hugo server and the Argo Tunnel processes are killed when you ctrl+c the terminal window.
cd /Users/samrhea/blog-samrhea
# This changes the directory to where my blog lives. Replace this with your own by running `pwd` in your blog directory and adding the output here.
hugo server -D &
# This starts a web server on port 1313 that runs the current edition of my Hugo blog.
sleep 3s
# This prevents a race condition where the tunnel would attempt to connect before the Hugo server was ready
cloudflared tunnel --url localhost:1313 &
# This creates a free Argo Tunnel and proxies requests to that port.
wait
# Make sure that you make this file executable first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.