Host Gitlab page on domain root (no subpath in URL)

I’d love to use Gitlab Pages to host my page on e.g. a custom domain, but without that subpath /project-name/ - reading the docs seemed like it’s not possible and googling didn’t really tell me anything :sweat:

Is it possible? If not, is there a Gitlab issue about it?

Hi,

Well according to the docs, no:

You could search the Gitlab issues and see if someone has opened an issue for it, and if nothing found you can open an issue for it. I expect though, considering that user/group pages are pinned to a DNS A record under the domain, that there shouldn’t be a reason for it not to work with project pages once Gitlab has been prepared to work that way.

2 Likes

Hi,

I’m not sure I understand the question. I’m assuming the following:

  1. You are using GitLab.com SaaS
  2. Instead of using the default gitlab.io domain with the following example

https://everyonecancontribute.gitlab.io/observability/o11y.love/

you’d like to just use a custom domain like

https://o11y.love/

?

That’s possible (the above example is already live). You’ll need to follow the documentation to

  1. add a custom domain to your project’s pages settings
  2. Add the required DNS records to your root domain’s zone
    2.1 A record pointing to the IP address
    2.2 TXT record providing the DNS challenge token received in the GitLab pages settings to verify you are the domain owner

Following above’s example, my DNS records look as follows in the Namecheap web interface.

Verified working on the CLI. dig is a command line tool to query DNS records.

$ dig _gitlab-pages-verification-code.o11y.love txt

;; ANSWER SECTION:
_gitlab-pages-verification-code.o11y.love. 1799	IN TXT "gitlab-pages-verification-code=<token_from_gitlab_pages_settings>"

$ dig o11y.love A

;; ANSWER SECTION:
o11y.love.		817	IN	A	35.185.44.232

Note that I prefer to use the A record with an IP address. Alternative methods suggested in the docs specify to create a CNAME/ALIAS record. Keeping the A record is easier imho, but needs the following knowledge: If the GitLab Pages IP address changes in the future, this will be announced and one can plan accordingly to update DNS records.

Can you share your custom domain name and settings you’ve done thus far?

Cheers,
Michael

2 Likes