Creating My Own Static Website III

Saturday, December 19, 2020

GitHub Pages

GitHub Pages is a service that allows us to host our static website directly from our repository on GitHub for free. They even let you expel a certificate for your website and configure a custom domain name.

So I planned to use GitHub Pages as a hosting service for my website, Cloudflare for managing my DNS zone and as a reverse proxy to improve the performance of my content delivery, and both of them to have free certificates.

As I’m using hugo for building my static website I can’t publish my whole repository as a website, because there’re a lot of files that the website doesn’t need. At first, I thought of some complicated way of CI/CD with GitHub Actions, a great new service that I wanted to try, but GitHub Pages allows you to configure a publishing source, so I just needed to configure on my config.toml the right directory.

publishDir = “docs”

Finally, this is how I update my website, I create a new Markdown file, with the content that I want, test it locally with the following command and when I am happy with the result I build the static content and push it to the repository. Github Pages and Cloudflare are responsible for everything else.

HUGO_ENV=production hugo server # Command to test the new content locally

HUGO_ENV=production hugo –minify # Command to build the static content

Alejandro Quiros

Creating My Own Static Website II