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

This explains the DNS part, but it doesn’t seem to address the path portion.
There different types of Gitlab pages: user pages, group pages, and project pages.
If you want the website to be hosted at https://yourdomain.com/ instead of yourdomain.com then you will have to user user pages or group pages.

Here is a documentation page that explains things in more detail:

@tennox were you able to solve this? I have the same problem.
@dnsmichi do you know anything about this?

We are a large engineering organization and would like to use Gitlab pages to publish some static websites and have custom domains per page.

repo 1: gitlab.com/orgname/group1/projecta
projecta.something.io/ would point to orgname.gitlab.io/groupt1/projecta

repo 2: gitlab.com/orgname/group2/projectb
projectb.com/ would point to orgname.gitlab.io/group2/projectb

Is this possible with Gitlab? Or can we only map a domain to the organization?

As far as I know there is an open issue about it, best post there.
I just solved it by generating the static html with the base url set to the project path as i’m building in the same pipeline

Ok but that means you still have to call customdomain.io/subproj/path - the domain doesn’t point directly to that site, right?

Yes, but the org.gitlab.io/project variant in my case.

For other things I just self host or netlify :tipping_hand_man:

Looks like I have to move these projects out of org then :frowning: