3 minutes
Netlify Setup
So, I have tried everything from static site generators hosted on AWS instances, NATted 128mb hosts, WordPress hosted on Digital Ocean, Vultr, and even self hosting on a Pi at home. Needless to say, there are compromises with each, whether it is cost, time/ease of management, and maintenance. Oh the maintenance. As someone who works a lot, I do not want to have to worry about outdated Wordpress plugins, critical OS patches for the latest and greatest vulnerability, or worring if my power/internet go down. While doing some research on a new static site generator, I found Hugo, and more importantly, Netlify. Setup is pretty easy, bu not completly straightforward. That is what this post is for, going through some of the nuances and showing my workflow.
Go ahead and setup the site how you want, a great kickoff to that is the Hugo quickstart guide - https://gohugo.io/getting-started/quick-start/
After you have your site running local and validated that everything works, follow this guide to setup Git and Netlify - https://gohugo.io/hosting-and-deployment/hosting-on-netlify/
Great. Now that is done, you will probably get a 404 error for your Blog or any new sections. What you will want to do is 1. rename your posts/blog files to markdown (.md), example: about_me.md and ensure that you have the proper heirachy as found on the Hugo docs page: https://gohugo.io/content-management/organization/
.
└── content
└── about
| └── index.md // <- https://example.com/about/
├── posts
| ├── firstpost.md // <- https://example.com/posts/firstpost/
| ├── happy
| | └── ness.md // <- https://example.com/posts/happy/ness/
| └── secondpost.md // <- https://example.com/posts/secondpost/
Lastly, I setup a small script push.sh
to help me quickly make a random commit and then have the change replicated to the site. First, setup an alias to git config --global alias.yolo '!git commit -m "$(curl -s whatthecommit.com/index.txt)"'
then open vim/nano to create a small bash file:
➜ netlify-bryanlurer git:(master) ✗ cat push.sh
#!/bin/bash
git add .
git yolo
git push
After youve saved the file, chmod +x push.sh
and then ./push.sh
to push.
➜ netlify-bryanlurer git:(master) ✗ ./push.sh
[master 952c2f0] Add Sandbox
2 files changed, 38 insertions(+), 4 deletions(-)
create mode 100644 content/posts/blog/netlify-setup.md
Warning: Permanently added the RSA host key for IP address to the list of known hosts.
Enumerating objects: 12, done.
Counting objects: 100% (12/12), done.
Delta compression using up to 4 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 1.67 KiB | 1.67 MiB/s, done.
Total 7 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To github.com:blurer/netlify-bryanlurer.git
aff649d..952c2f0 master -> master
And that is it. Everything is up and running.
432 Words
2020-07-03 04:48 +0000