If you’re looking to create a blog, you’re in luck! There are countless tools to help you get up and running in a few minutes. For example Hugo will generate a static site from a few markdown files, and pushing it to github in a repository named
YOUR_USERNAME.github.io will put you online.
That’s it! You’re done! ✨
However if it’s too easy it isn’t fun. Also by accepting what’s good enough, you might actually write content into your blog! Let’s not do that.
Here are my requirements:
- The website should be static. It makes hosting cheap or even free.
- Modifying any parts should be possible. I want control of my site.
- Once set-up, I should be able to focus on the content. No distraction from the command line, just press save and be done.
- Be able to edit from anywhere. That typo your friend noticed? Fix it with a quick edit from your phone!
The first two can be satisfied by any static site generator. The third can be solved by a nice tool like Publii, though it does make customizing details a bit more tricky. Editing from anywhere is easy with commercial offerings like WordPress, but the website is not static and I would need to give up a lot of control.
The solution for all four come from static content management system (CMS), which –as the name imply– will provide tools to manage your content and generate your static site.
If you want to look at the code directly, you can find it here. The steps below explain how to get there.
With the context out of the way, here are the necessary steps:
- Create a github repository matching your username, for example
jondoe.github.io(if you’re not familiar with git or github, head over there for some simple explanations). Once done
git clone https://github.com/jondoe/jondoe.github.io
- Install Hugo and follow the quick start guide. Now is a good time to choose a theme. Push the code Hugo created for you into a new repository, for example
- Once you’re done configuring your site to your liking, copy the generated static site (under
./public) to your
jondoe.github.iodirectory. Push, and admire your website at
- Now we can setup the CMS. Login with your github account into forestry.io and follow the quickstart guide. (I know, I said that for Hugo already, that’s the last one I promise!). You will want to link the
site_generatorrepo, not the one hosting your generated site itself. Now from forestry you will be able to write new content, however it’s not published to github pages yet.
- To automate the publishing, we will use github actions, that will allow us to push the changes to the static site into the right repository. Luckily some nice folks already did the job for us, so let’s use the example they provide. There are multiple ways to authenticate from your script, suggest using the deploy key.
That’s it! (again)
Now you can edit content from forestry, and upon saving your changes will be published automatically. After a blog post or two, internet fame should follow!
Author Paul Willot