OneBite.Dev - Coding blog in a bite size

Move My Hugo Site From Github Pages to Netlify

Today i move my static site using hugo from github-pages to netlify hosting provider

Today i move my static hugo site from github-pages to netlify. I heard a lot of good things about netlify before, but github-pages seems easier to use (less complicated) for me.

Tiny problem with github-pages

Until i found one “tiny” problem, i can’t schedule my post. Since the way github-pages serves our hugo site is by looking what’s inside our github public repo, we always have to deploy it manually at the exact time to trigger the changes. I start looking for answers in google, and many people suggest.. you guest it.. netlify!

Netlify has a lot of features, but the one i need right now is how to schedule post in the future, which i’ll talk at another post. It’s on! check How to scheduled Hugo post in future

What i did to move my hugo site to netlify:

What about Https and custom domain?

Don’t forget if you set custom domain for you github-pages before, now we have to reset it once again. Normally, after install your new netlify site, netlify will suggest to add your custom domain, if not, just go to settings > Domain management. And you’ll find the detailed info there.

You may also want to redirect the netlify subdomain, just create “_redirects” file (no file type) inside your static folder, not in root! {{< highlight Bash >}}* 301! {{< / highlight >}}

For the HTTPS, netlify use let’s encrypt for us automatically.

Automate deploy with one command

Now create a file in your root

echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"

# Add changes to git.
git add .

# Commit changes.
msg="rebuilding site `date`"
if [ $# -eq 1 ]
  then msg="$1"
git commit -m "$msg"

# Push source and build repos.
git push origin master

You just have to run “./” to push to your original repository

← How to Schedule Post in F...
Create New Hugo Post Fast... →
sharing hugo