In my recent note about my open-source changes, I mentioned about Codeberg. The whole platform is minimal and well-done for my use case (casual/hobby programming). So I was thinking of building something. I got one pending project in mind, a blogroll. I use Codeberg Pages and Using Custom Domain.

Getting started

Follow these simple steps below to get started.

  1. Create a public repository named ‘pages’ in your user account or organization.
  2. Create static content, HTML, stylesheets, fonts or images. Name the homepage file index.html.
  3. Push your content to the default branch of the new repository.
  4. You should now be able to access your content by visiting {{username}}.codeberg.page.

Custom domain

For custom domains, two things are required:

  • a .domains file in the repository and branch where your files reside which you want to publish via Codeberg Pages. The file should contain a list of all domains that shall be usable to access that repository, according to the following rules:
    • One domain per line, you can leave lines empty and comment out lines with #.
    • The first domain is the main domain, all other domains in the file will be redirected to the first one.
    • The rest of the list includes all relevant *.codeberg.page domains for the specific repository.
  • a DNS record pointing to one of the following targets, depending on where your static files reside:

Example of .domain:

blogroll.huytran.eu
quochuytran.codeberg.page

Setting the DNS record

There are several ways DNS records for your website can be setup in order to tell the Pages server your repository location. For all of the options it is important that the Pages server knows where to look for the .domains file and your content. Depending on from where you want to serve your files, there is a naming scheme for the domain:

Domain SchemePages URL
username.codeberg.pagehttps://username.codeberg.page
which will serve codeberg.org/username/pages
reponame.username.codeberg.pagehttps://username.codeberg.page/reponame
which will serve codeberg.org/username/reponame
branchname.reponame.username.codeberg.pagehttps://username.codeberg.page/reponame/@branchname/
which will serve codeberg.org/username/reponame/src/branch/branchname
The easiest and recommended way is to just setup a CNAME record for your domain, pointing to the mentioned above locations. In the end, it should look like this:
DomainTypeData
yourdomain.comCNAMEreponame.username.codeberg.page
www.yourdomain.comCNAMEreponame.username.codeberg.page
I want to use Codeberg page as my subdomain website, so it looks like the following: