GitHub to Codeberg Migration - Part 2 - Codeberg Pages

In this blog post, I'd like to describe my experience with the migration of hosting websites from Netlify to Codeberg Pages.

Starting Point

As I described in my previous post, I have two website projects, a blog and my personal homepage. Both were hosted on Netlify.

With the repository migration from GitHub to Codeberg (as described in a previous blog post), I also wanted to change the hosting location of both websites. Codeberg offers a GitHub Pages-similar service called Codeberg Pages. The software behind Codeberg Pages is in a maintenance mode, which means bug fixes are accepted but no new features. Maybe I will search for another solution for my websites in the future, but currently, Codeberg Pages matches my requirements.

Codeberg Pages Set up

Hosting static content

The condition for using Codeberg Pages is that your repository is hosted on Codeberg. Codeberg Pages has two options for hosting a static website:

  1. Creating a public repository named pages or
  2. Creating a branch pages in a public repository.

Independent of the chosen option, you have to push your static content to the repository or branch, respectively.

I choose option 2 because I want to have two websites.

Custom domains

Next next step is to configure custom domains. Codeberg Pages has a predefined URL for the website (dependent on the chosen option), but it also has the option to use a custom domain for the websites (documentation).

The first step is that you have to add a .domains file in the repository/branch where your static content is. This file contains all domains that should be usable to access that repository.

In my case, I need for each repository a separate .domains file:

1www.yourdomain.com
2reponame.username.codeberg.page
3branchname.reponame.username.codeberg.page

and

1subdomain.yourdomain.com
2reponame2.username.codeberg.page
3branchname.reponame2.username.codeberg.page

The one of the last two domains in each file is important for the domain record that you have to set at your DNS service provider (Codeberg's documentation explains the why).

The next step is to set the DNS record. Codeberg Pages supports three options:

  1. CNAME record
  2. ALIAS record
  3. A/AAAA record

I have to use option 3 because my DNS service provider does not support ALIAS records, and I could not use the CNAME record option because I use the domains as well for e-mails. So my DNS records look like the following one:

1yourdomain.com A 217.197.84.141
2yourdomain.com AAAA 2a0a:4580:103f:c0de::2
3yourdomain.com TXT reponame.username.codeberg.page
4www.yourdomain.com CNAME reponame.username.codeberg.page

and

1subdomain.yourdomain.com A 217.197.84.141
2subdomain.yourdomain.com AAAA 2a0a:4580:103f:c0de::2
3subdomain.yourdomain.com TXT reponame2.username.codeberg.page

At the end, I have to add a .domains file in each repository and add DNS records for both websites. Configuring DNS records is for me always a pain in the ass, but Codeberg's documentation helps a lot. In special, there are good examples that explain what you have to do.

The next step in my migration journey is to find a solution for an automated deployment for the website. So I will give Forgejo Action a try.