How to migrate multiple static websites from GitHub pages to Codeberg

The official documentation can be found on https://codeberg.page, but I think it is confusing and incomplete if you want multiple pages and are using a custom domain name.


Getting your repository on Codeberg

So, on the official documentation they say one has to create a repository named “pages” for the static website, but then what if one has multiple websites? It's also plain annoying to have such a name for a repository. Anyway, the following steps allow you to have multiple static pages on Codeberg without having to name them “pages”, ugh.

  1. Create an account on Codeberg: https://codeberg.org/user/sing_up *. Then via the top right button click “+ New Repository”. Choose whatever repository name, and as “Default Branch” replace main with pages. Click “Create Repository”.
  2. Go to the directory on your local machine of which you want the content into your newly created Codeberg repository. For me that was “/home/…/quitfacebook.org/public/”

Option 1: keep git history

This will save the nice graph that shows all the contributions you made, and all the file versioning history of course.

      git remote rename origin old-origin-github
      git remote add origin https://codeberg.org/CynicusRex/quitfacebook.git
      git branch -M pages
      git push --set-upstream origin --all
      git push --set-upstream origin --tags
    

Option 2: remove git history

  1. Assuming you still have the hidden .git folder, rename it to .git_BAK or whatever, or delete it.
  2. Open the terminal in that directory and run: git init It will probably show you the following message: “hint: Using 'master' as the name for the initial branch. This default branch name […] The just-created branch can be renamed via this command: git branch -m <name>”
  3. Run: git branch -m pages You see, the repository needn't be named pages, but the branch does. Which is great because now we can have multiple pages with distinct names. The official documentation makes it seem as if one is limited to one page.
  4. Run:
    git add .
    git commit -m "first commit"
    git remote add origin https://codeberg.org/CynicusRex/quitfacebook.git
    git push -u origin pages

– – – – –

* This typo is intentional, apparently.

Domain configurations*

Assuming you have a custom domain name, do the following. If you don't, then the official documentation probably suffices.

  1. Add the file “.domains” to your local repository with the following content, obviously adjusted to your own domain name, and push it to Codeberg:
    quitfacebook.org
    www.quitfacebook.org
    pages.quitfacebook.cynicusrex.codeberg.page
  2. Go to your registrar website, and configure the “Advanced DNS” “host records” as follows:
    Type: A Record, Host: @, Value: 217.197.91.145, TTL: Automatic
    Type: AAAA Record, Host: @, Value: 2001:67c:1401:20f0::1, TTL: Automatic
    Type: CNAME Record, Host: www, Value: quitfacebook.cynicusrex.codeberg.page., TTL: Automatic
    Type: TXT Record, Host: @, Value: quitfacebook.cynicusrex.codeberg.page., TTL: Automatic

All is done. Now you might have to wait for a couple of hours until the domain configurations get updated. Also, don't forget to unpublish your page on GitHub.

Enjoy your day.

—Angelino Desmet; 15 April 2023.

Latest edit: 28 July 2023.

– – – – –

* Credits to Jan Wildeboer for helping with this.

Ψ

Comments

Search for https://fosstodon.org/@stardust/110202336827539450 (fosstodon invite) on your preferred Mastodon server while logged in, comments appear below.