For some irrelevant reasons, I decided to move my website (and my library) to be hosted on Codeberg. So, I am going to write a little bit about how I did the migration.
First, I created an account on Codeberg.
There are tons of useful tutorials and documentations on the web that explain how to migrate repositories from GitHub to Codeberg.
It’s important to note that on GitHub, you usually have to name your repository in a specific way to make GitHub Pages work.
In Codeberg, you technically can do the same (with the pages repository name), but I found it easier to configure everything with a general repository name.
So, I recommend you to name your website’s repository whatever (mine is named website).
The way Codeberg Pages works is a bit more bare-bones than GitHub Pages.
Here, you have to create a standard html, css, and js structure, and there is no easy shortcut for Hugo websites.
So, what we usually do is build the Hugo website (by default under the public/ folder) and then we save the built website on a separate branch of the repository.
Finally, we deploy this second branch and leave the main branch for the source code.
To this end, you must configure your Codeberg Actions.
These are .yml files that are under .forgejo/workflows.
Before writing anything, one must enable Actions under Repository Settings > Units > Overview > Actions and checking the box that read “Enable integrated CI/CD pipelines with Forgejo Actions”.
Below you can check a sample action definition that publishes the website.
Please read it carefully.
| |
Please, notice that we must have the .domains file both in the main branch in in the branch that is going to be published.
This file basically specifies which custom domains serve this website.
It should look like the following.
| |
Once you have the action configured, you must now setup your DNS Settings.
This heavily depends on your registrar, but Codeberg’s documentations are really good.
Just be sure to remove the A and CNAME records from GitHub and remember to set the TXT record with all information:
branch.repository.username.codeberg.page.
After everything, your website should work. Let me know if I forgot any crucial step.