2023-07-08 09:27:44 -07:00
---
eleventyNavigation:
key: UsingCustomDomains
title: Using Custom Domains
parent: CodebergPages
order: 10
---
2025-06-14 02:38:21 -07:00
Instead of using the `codeberg.page` domain, you can also purchase your own domain from a domain registrar of your choice
and configure it to serve content from Codeberg Pages.
2023-07-08 09:27:44 -07:00
2023-11-26 21:45:00 -08:00
{% admonition "warning" "Known pitfalls for failed certificate errors" %}
2025-06-14 02:38:21 -07:00
If you have a [CAA record ](https://en.wikipedia.org/wiki/DNS_Certification_Authority_Authorization#Record ) configured,
you must [explicitly allow Let's Encrypt in your CAA record ](https://letsencrypt.org/docs/caa/ ).
2024-11-26 18:49:34 -08:00
The value of the CAA record would look like `letsencrypt.org;accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/292520050;validationmethods=tls-alpn-01,http-01` .
2023-11-26 21:45:00 -08:00
{% endadmonition %}
2023-07-08 09:27:44 -07:00
For custom domains, two things are required:
2025-11-21 03:35:05 -08:00
- 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 external domains that shall be usable to access that repository,
according to the following rules:
2023-07-08 09:27:44 -07:00
- 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.
2025-06-14 02:38:21 -07:00
- a [DNS record ](https://en.wikipedia.org/wiki/Domain_Name_System#Address_resolution_mechanism ) pointing to one of the
following targets, depending on where your static files reside:
2023-07-08 09:27:44 -07:00
< br / >
2023-11-26 21:45:00 -08:00
{% admonition "question" "Why do I need all of these DNS records?" %}
2025-06-14 02:38:21 -07:00
To understand how the Pages server serves content, you need to know that a user browsing your custom domain just sends
"Hey, I want to see `yourdomain.com` " to the server.
But the server might not know that it is responsible for `yourdomain.com` and it cannot just serve all domains in the world.
So to find out if the server is responsible for `yourdomain.com` it will check the DNS entries of `yourdomain.com` .
If it returns something with `codeberg.page` (according to the domain schemes mentioned below) then it knows which
respository to check for the `.domains` file and your content.
2023-11-26 21:45:00 -08:00
{% endadmonition %}
2023-07-08 09:27:44 -07:00
## Setting the DNS record
2025-06-14 02:38:21 -07:00
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:
2023-07-08 09:27:44 -07:00
< table class = "table" >
2025-06-16 13:57:17 -07:00
< thead >
< th > Domain Scheme< / th >
< th > Pages URL< / th >
< / thead >
< tbody >
< tr >
< td >
< code > username.codeberg.page< / code >
< / td >
< td >
https://username.codeberg.page< br / > which will serve < code > codeberg.org/username/pages< / code >
< / td >
< / tr >
< tr >
< td >
< code > reponame.username.codeberg.page< / code >
< / td >
< td >
https://username.codeberg.page/reponame< br / > which will serve < code > codeberg.org/username/reponame< / code >
< / td >
< / tr >
< tr >
< td >
< code > branchname.reponame.username.codeberg.page< / code >
< / td >
< td >
https://username.codeberg.page/reponame/@branchname/< br / >
which will serve < code > codeberg.org/username/reponame/src/branch/branchname< / code >
< / td >
< / tr >
< / tbody >
2023-07-08 09:27:44 -07:00
< table >
2025-09-12 06:32:49 -07:00
{% admonition "warning" "Repository names with dots are not supported" %}
2025-11-21 03:35:05 -08:00
Repository names containing dots (`.`) are **not supported** for custom domains.
The Pages server uses dots as delimiters to parse the repository name, branch, and owner from DNS records.
2025-09-12 06:32:49 -07:00
2025-11-21 03:35:05 -08:00
For example, if your repository is named `my.project` , the TXT record `my.project.username.codeberg.page`
will be incorrectly parsed as:
2025-09-12 06:32:49 -07:00
- Branch: `my`
- Repository: `project`
- Owner: `username`
2025-11-21 03:35:05 -08:00
**Solution:** If you need to use a custom domain, rename your repository to use hyphens (`-`) or
underscores (`_`) instead of dots. For example, rename `my.project` to `my-project` .
2025-09-12 06:32:49 -07:00
{% endadmonition %}
2025-06-14 02:38:21 -07:00
_We assume for the following description, that you want to serve your website with and without www in front.
If you are on a subdomain already (like myproject.yourdomain.com), you can skip the `www.yourdomain.com` CNAME entry._
2023-07-08 09:27:44 -07:00
2024-06-09 07:23:36 -07:00
{% admonition "Warning" %}
2025-06-14 02:38:21 -07:00
When setting up DNS records with many registrars, any domain added to the `Domain` or `Host` option is automatically
appended onto the domain the records are being made for.
2024-06-09 07:23:36 -07:00
For example, if your domain is `example.com` , entering `www` will mean the record refers to `www.example.com` .
2025-06-14 02:38:21 -07:00
Therefore, in this guide, you may need to replace references to just your domain name (e.g. `example.com` ) with `@` and
`anything.example.com` (i.e. any subdomain) with just `anything` .
2024-06-09 07:23:36 -07:00
{% endadmonition %}
2025-06-14 06:39:01 -07:00
### Option 1: CNAME record
2023-07-08 09:27:44 -07:00
2025-06-14 02:38:21 -07:00
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:
2024-06-11 00:51:22 -07:00
2023-07-08 09:27:44 -07:00
< table class = "table" >
2025-06-16 13:57:17 -07:00
< thead >
< th > Domain< / th >
< th > Type< / th >
< th > Data< / th >
< / thead >
< tbody >
< tr >
< td > yourdomain.com< / td >
< td > CNAME< / td >
< td > reponame.username.codeberg.page< / td >
< / tr >
< tr >
< td > www.yourdomain.com< / td >
< td > CNAME< / td >
< td > reponame.username.codeberg.page< / td >
< / tr >
< / tbody >
2023-07-08 09:27:44 -07:00
< / table >
< br / >
2023-11-26 21:45:00 -08:00
{% admonition "Warning" %}
2025-06-14 02:38:21 -07:00
With a CNAME record everything on this domain is delegated to `codeberg.page` , which means you cannot setup your own
email address with this method.
2023-11-26 21:45:00 -08:00
If you need email or others services, you have to use one of the remaining options.
{% endadmonition %}
2023-07-08 09:27:44 -07:00
2025-06-14 06:39:01 -07:00
### Option 2: ALIAS record
2023-07-08 09:27:44 -07:00
If you cannot use a CNAME record to configure the target you can use this method, which needs two entries instead of one.
2025-06-14 02:38:21 -07:00
- First you need to specify which server should be serving your website. Similar to CNAME you can use an `ALIAS record` .
The [difference ](https://www.ecosia.org/search?q=cname%20vs%20alias%20record ) between an CNAME record is,
that the DNS server directly responds with the ip address and not the `codeberg.page` domain.
Therefore you need to add a second entry, so that the pages server knows what to serve under this domain.
- Second, you need to setup a `TXT record` which contains the information from the `CNAME entry` which is your repository
location as mentioned above. For example `[[branch.]repo.]user.codeberg.page` .
2023-07-08 09:27:44 -07:00
In the end it should look like this:
< table class = "table" >
2025-06-16 13:57:17 -07:00
< thead >
< th > Domain< / th >
< th > Type< / th >
< th > Data< / th >
< / thead >
< tbody >
< tr >
< td > yourdomain.com< / td > < td > ALIAS< / td > < td > codeberg.page< / td >
< / tr >
< tr >
< td > yourdomain.com< / td > < td > TXT< / td > < td > reponame.username.codeberg.page< / td >
< / tr >
< tr >
< td > www.yourdomain.com< / td > < td > CNAME< / td > < td > reponame.username.codeberg.page< / td >
< / tr >
< / tbody >
2023-07-08 09:27:44 -07:00
< / table >
2025-06-14 06:39:01 -07:00
### Option 3: A/AAAA record
2023-07-08 09:27:44 -07:00
If your service provider does not support `ALIAS records` you can also use `A records` and `AAAA records` instead.
2025-06-14 02:38:21 -07:00
- First you need to specify which server should be serving your website. You can do this by setting an `A record` for IPv4
and an `AAAA record` for IPv6 which contains the ip address of the Codeberg Pages server. The servers' ip addresses are:
2025-04-23 06:43:54 -07:00
- `A record` which contains the IPv4 value `217.197.84.141`
- `AAAA record` which contains the IPv6 value `2a0a:4580:103f:c0de::2`
2025-09-14 04:28:09 -07:00
- Second, you need to setup a `TXT record` which contains the information of your repository
2025-06-14 02:38:21 -07:00
location as mentioned above. For example `[[branch.]repo.]user.codeberg.page` .
2023-07-08 09:27:44 -07:00
In the end, it should look like this:
< table class = "table" >
2025-06-16 13:57:17 -07:00
< thead >
< th > Domain< / th >
< th > Type< / th >
< th > Data< / th >
< / thead >
< tbody >
< tr >
< td > yourdomain.com< / td >
< td > A< / td >
< td > 217.197.84.141< / td >
< / tr >
< tr >
< td > yourdomain.com< / td >
< td > AAAA< / td >
< td > 2a0a:4580:103f:c0de::2< / td >
< / tr >
< tr >
< td > yourdomain.com< / td >
< td > TXT< / td >
< td > reponame.username.codeberg.page< / td >
< / tr >
< / tbody >
2023-07-08 09:27:44 -07:00
< / table >
## Examples
The following sub-sections include a few examples of the different alternatives, assuming the following:
- we can add/modify DNS records in domain `example.com` .
- Our Codeberg username is `frida` , and we want to publish pages for:
2024-06-11 00:51:22 -07:00
- `frida/pages` , with a _Personal_ static site inside branch `pages` ;
- `frida/colormix` , with a _Project_ site (again, inside branch `pages` ).
2023-07-08 09:27:44 -07:00
2025-06-14 02:38:21 -07:00
All considerations regarding a _Personal_ site also apply to an _Organization_ site, so these two cases will be
addressed together.
2023-07-08 09:27:44 -07:00
2025-10-30 09:05:41 -07:00
### Personal (or Organization) site, subdomain
2023-07-08 09:27:44 -07:00
2024-06-11 00:51:22 -07:00
In this case, we want our _Personal_ pages available at the URL `https://myself.example.com` .
2023-07-08 09:27:44 -07:00
The `.domains` file contains the following:
2025-06-14 06:39:01 -07:00
```text
2023-07-08 09:27:44 -07:00
myself.example.com
```
For the DNS configuration:
2025-11-21 03:35:05 -08:00
- if the domain is not the apex of the zone and does not have other services such as email,
you should always use a CNAME record:
2024-06-11 00:51:22 -07:00
- name `myself.example.com` , type `CNAME` , data `frida.codeberg.page`
2023-07-08 09:27:44 -07:00
- otherwise, if ALIAS can be used, two DNS records will be needed:
2024-06-11 00:51:22 -07:00
- name `myself.example.com` , type `ALIAS` , data `codeberg.page`
- name `myself.example.com` , type `TXT` , data `frida.codeberg.page`
2023-07-08 09:27:44 -07:00
- otherwise, A/AAAA records must be used, together with one TXT record:
2025-04-23 06:43:54 -07:00
- name `myself.example.com` , type `A` , data `217.197.84.141`
- name `myself.example.com` , type `AAAA` , data `2a0a:4580:103f:c0de::2`
2024-06-11 00:51:22 -07:00
- name `myself.example.com` , type `TXT` , data `frida.codeberg.page`
2023-07-08 09:27:44 -07:00
### Personal/Organization site, apex domain
2025-11-21 03:35:05 -08:00
In this case, we want our _Personal_ /_Organization_ pages available at the URL `https://example.com` .
We also want the URL `https://www.example.com` to redirect to the apex domain.
2023-07-08 09:27:44 -07:00
The `.domains` file contains the following:
2025-06-14 06:39:01 -07:00
```text
2023-07-08 09:27:44 -07:00
example.com
2025-10-30 09:05:41 -07:00
www.example.com
2023-07-08 09:27:44 -07:00
```
2025-11-21 03:35:05 -08:00
_You may also put the `www` subdomain on the first line if you wish to use it as the canonical URL_
_and redirect the apex domain instead._
2023-07-08 09:27:44 -07:00
2025-10-30 09:05:41 -07:00
For the DNS configuration, CNAME records CANNOT be used for the apex domain, so:
- if ALIAS can be used, three DNS records will be needed:
2024-06-11 00:51:22 -07:00
- name `example.com` , type `ALIAS` , data `codeberg.page`
- name `example.com` , type `TXT` , data `frida.codeberg.page`
2025-10-30 09:05:41 -07:00
- name `www.example.com` , type `CNAME` , data `frida.codeberg.page`
2023-07-08 09:27:44 -07:00
2025-10-30 09:05:41 -07:00
_Note that ALIAS records are not real DNS records and are typically incompatible with DNSSEC signed zones._
- otherwise, A/AAAA records must be used, together with a TXT record:
2025-04-23 06:43:54 -07:00
- name `example.com` , type `A` , data `217.197.84.141`
- name `example.com` , type `AAAA` , data `2a0a:4580:103f:c0de::2`
2024-06-11 00:51:22 -07:00
- name `example.com` , type `TXT` , data `frida.codeberg.page`
2025-10-30 09:05:41 -07:00
- name `www.example.com` , type `CNAME` , data `frida.codeberg.page`
2023-07-08 09:27:44 -07:00
2025-10-30 09:05:41 -07:00
### Project site, subdomain
2023-07-08 09:27:44 -07:00
2024-06-11 00:51:22 -07:00
In this case, we want our _Project_ pages available at the URL `https://colormix-app.example.com` .
2023-07-08 09:27:44 -07:00
The `.domains` file contains the following:
2025-06-14 06:39:01 -07:00
```text
2023-07-08 09:27:44 -07:00
colormix-app.example.com
```
For the DNS configuration:
2025-11-21 03:35:05 -08:00
- if the domain is not the apex of the zone and does not have other services such as email,
you should always use a CNAME record:
2024-06-11 00:51:22 -07:00
- name `colormix-app.example.com` , type `CNAME` , data `colormix.frida.codeberg.page`
2023-07-08 09:27:44 -07:00
- otherwise, if ALIAS can be used, two DNS records will be needed:
2024-06-11 00:51:22 -07:00
- name `colormix-app.example.com` , type `ALIAS` , data `codeberg.page`
- name `colormix-app.example.com` , type `TXT` , data `colormix.frida.codeberg.page`
2023-07-08 09:27:44 -07:00
- otherwise, A/AAAA records must be used, together with one TXT record:
2025-04-23 06:43:54 -07:00
- name `colormix-app.example.com` , type `A` , data `217.197.84.141`
- name `colormix-app.example.com` , type `AAAA` , data `2a0a:4580:103f:c0de::2`
2024-06-11 00:51:22 -07:00
- name `colormix-app.example.com` , type `TXT` , data `colormix.frida.codeberg.page`
2023-07-08 09:27:44 -07:00
### Project site, apex domain
2024-06-11 00:51:22 -07:00
In this case, we want our _Project_ pages available at the URL `https://example.com` .
2023-07-08 09:27:44 -07:00
2023-11-26 21:45:00 -08:00
{% admonition "info" "Note" %}
2025-06-14 02:38:21 -07:00
This would be incompatible with using the apex `example.com` for other purposes, e.g. for the _Personal_ /_Organization_
example discussed before.
2023-11-26 21:45:00 -08:00
{% endadmonition %}
2023-07-08 09:27:44 -07:00
The `.domains` file contains the following:
2025-06-14 06:39:01 -07:00
```text
2023-07-08 09:27:44 -07:00
example.com
2025-10-30 09:05:41 -07:00
www.example.com
2023-07-08 09:27:44 -07:00
```
2025-11-21 03:35:05 -08:00
_You may also put the `www` subdomain on the first line if you wish to use it as the canonical URL_
_and redirect the apex domain instead._
2023-07-08 09:27:44 -07:00
2025-10-30 09:05:41 -07:00
For the DNS configuration, CNAME records CANNOT be used for the apex domain, so:
- if ALIAS can be used, three DNS records will be needed:
2024-06-11 00:51:22 -07:00
- name `example.com` , type `ALIAS` , data `codeberg.page`
- name `example.com` , type `TXT` , data `colormix.frida.codeberg.page`
2025-10-30 09:05:41 -07:00
- name `www.example.com` , type `CNAME` , data `colormix.frida.codeberg.page`
_Note that ALIAS records are not real DNS records and are typically incompatible with DNSSEC signed zones._
2023-07-08 09:27:44 -07:00
- otherwise, A/AAAA records must be used, together with one TXT record:
2025-04-23 06:43:54 -07:00
- name `example.com` , type `A` , data `217.197.84.141`
- name `example.com` , type `AAAA` , data `2a0a:4580:103f:c0de::2`
2024-06-11 00:51:22 -07:00
- name `example.com` , type `TXT` , data `colormix.frida.codeberg.page`
2025-10-30 09:05:41 -07:00
- name `www.example.com` , type `CNAME` , data `colormix.frida.codeberg.page`