title: GitLab Pages + Namecheap date: June 29, 2019 ---
This website is currently hosted as a GitLab Pages page. In addition to the free m-chrzan.gitlab.io domain name that GitLab provides, it's also pointed to by m-chrzan.xyz. This was my first time hosting a static site and interacting with a domain name registrar/DNS settings, so I wanted to write down some thoughts and tips while it's all still fresh in my mind.
Unlike some other static site hosts (like GitHub Pages), GitLab doesn't have you just upload the html/css/js files for your static site and host them directly, but gives you the option to maintain a repo that uses some sort of static site generator (say Jekyll, a popular option). It then has you use the gitlab-ci system available for every repo to actually compile the website, and if that succeeds, makes your website available.
You still have the option to host a set of plain html files, and GitLab provides a template for that setup.
One slight point of confusion I encountered was when I missed that the build
directory has to be called public
. Just looking at different
.gitlab-ci.yml
examples, I thought GitLab would look under whatever
path was specified with
Initially my generator was putting build files in a
pages:
artifacts:
paths:
- <path>
build
directory. This would result in my CI build succeeding, but the external build
that GitLab does to actually publish the website would fail, without a useful
error message. A little embarassing how much time I spent debugging this one...
I picked Namecheap as my registrar because they're considered reliable, have cheap registration (got this .xyz for $1 for the first year!), and they're not GoDaddy. Registration and payment was super simple, would recommend. The DNS configuration page can be slow to respond unfortunately.
I've never played around with configuring DNS records, but GitLab's documentation had fairly clear explanations. The biggest gripe I had was that the official documentation recommends against using a CNAME record , while the Pages UI under my repo had a CNAME record (and no A record) made available for copying, as if that were the recommended route. I ended up creating an A record pointing to 35.185.44.232 as described in the docs.
I had a few issues that I'm not sure if they were caused by Namecheap or just expected DNS propagation delays. It took several hours for the A record to appear in DNS queries. Additionally, I missed the part where when creating the TXT record that verifies ownership of a domain name, if you're creating it for an A record, you should just use your top-level domain. Again, confusingly, the Pages UI provides a copyable text field to a dummy subdomain and I had to dig through the docs to find the correct approach.