Hosting hugo blog on cloudfare for free
Contents
recently I had tested to deploy Hugo site on cloudfare pages,
the process is much like hugo netlify deplyment,
the web page speed is pretty good,
the build process is straighforward,
and it’s free?:
cloudfare page is:
- Developer-focused with effortless Git integration. you can write/update your blogs locally, and then git push to github, the rest actions(fetch the update, recompile the project, deploy)is automatically done by cloudfare page.
- Advanced collaboration built-in with unlimited seats. you can invite your teams/friends/family to cooperate on on your projects
- Unmatched performance on Cloudflare’s edge network. This is what cloudfare is for–CDN acceleration. The hosted hugo project is static, it is prefect condidate for cdn acceleration.
- Dynamic functionality with Cloudflare Workers. You can utilize Cloudfare’s workers to do some dynamic jobs or tasks to build a dynamic site.
to register an account, please visit cloudfare pages. After registration, visit your email to finish the email verification.
create a new hugo project on GitHub
Hugo quick start
please follow instruction on Hugo Quick Start Guide
and this time, I created a new hugo project repo on Github at https://github.com/guanyc/hugo-one-click
it is a hugo project with ananke theme and one page.
create cloudfare page
link github
let’s create cloudfare page, now the cloudfare Page looks like this
click the Pages link on the right,click the Create a Project Buttonconnect your github connetauthorize your github repo to cloudfareselect “only select repositories”, and here choose your hugo repo to be connected with cloudfare, then clikc “install and Authorize”github will ask your password if necessaryverify your github account and repo is correct again, then click “Begin Setep”
cloudfare hugo settings
build settings,
select “Hugo” for framework preset, “hugo” for build commandclick “Add variable” below Environment variables(advanced), and add “HUGO_VERSION” with value 0.81.0(or your version, should be recent hugo + extended version, im using 0.83.1), then start build.
build process
you can see the build logs
|
|
build logs, now click “Continue to project”
your pages landing page, click the sub domain link to visit your pages
your pages
try to add another post
git push your second second post and see the pages.
sum up
In all, Cloudfare is great for hosting static pages, git integration for automatic deploy actions, the speed is really good. and it is free(500 build a month is enough for normal users). Please add the HUGO_VERSION to you local dev version, otherwise couldfare will fetch hugo 0.54.0 version, which would probably cause build failure.
I suggest Hugo static generator framework, you can write your post use Markdown, and manage versions with GIT, leaving the rest to Github and Cloudfare/Netlify/Others, all are free, which are sufficitent for beginning blogs/resume/small websites.