Migrating to Codeberg Pages
Hello world, from Codeberg Pages!
I’ve gotten so tired of GitHub’s and Microsoft’s forced shenanigans—enough so that I’ve migrated over to Codeberg. It was a fairly painless experience switching over and would recommend it to anybody. There’s much less clutter, more privacy (no weird tracking & ads), and its community seems to be much nicer overall.
Here’s how I’ve migrated over my Github Pages to Codeberg Pages, complete with an action to build the static content.
Project structure
The project is organized using its branches:
mainwhere the source code resides, and where I would do PRs topagesthe compiled pages generated by Jekyll, i.e. whereindex.htmllives
(Note: there are several ways of doing this. I’m using separate branches because it keeps the main branch clean of generated files.)
Actions
On Github, there was a built-in action for deploying to Github pages. This made it very easy to deploy a static page.
On Codeberg, it required a little setup: namely a Forgejo Action. I based this Forgejo action on the quick start guide and the example Hugo action which does something similar.
The Action works by running a series of steps when we push a commit onto main. The steps are:
- On the build job: Cloning the repo from
main - Installing dependencies (Ruby from
apt-get, and the Jekyll dependencies) - Builds the static files and places them into a temporary directory,
_site/- This also copies over the
.domainsfile
- This also copies over the
- Uploads them as artifacts (I think these steps can be omitted), including hidden files like the
.domainsfile - On the deploy job: downloads the artifacts
- Copies the generated files onto the branch
pages
The full workflow is listed in the repo.
DNS
I followed the instructions and use A/AAAA/TXT records to point the domain to the Codeberg page. For the TXT record, I had to use the branch.repo.username scheme (pages.pages.kevinhikaruevans.codeberg.page in this case).
I’m using Cloudflare for this and although the docs recommend not using the Cloudflare caching, I enabled it anyway and it seems to be alright. There’s some slowness in Codeberg pages, probably caused by me living across the world from the servers, and using Cloudflare’s caching helps speed things up. I presume it would be fine to use Cloudflare’s caching here, since I’m only using a single domain.