GitLab is on a roll.
They are, and have been, gaining a lot of steam in winning over professionals and laymen alike (i.e. me). When I found my educational promotion on GitHub was about to expire, along with access to free private repos, I turned to GitLab. They are really trying to make you feel inclined to do the same.
Rolling out a static website on GitHub is a bit easier than GitLab. This is mainly because their documentation is a bit more “follow x-y-z”, and they handle more things automatically (e.g. GitLab requires setting up a pipeline). But once you sort out barely more complicated DNS settings and follow a guide on a no-frills .gitlab-ci.yml file to configure said pipeline, you should be in business with GitLab pages.
Here is what I did:
- Already have a functioning static HTML website in a git repo (which was hosted on GitHub). I also already have multiple domains registered, with various [DNS] settings pre-configured for redirects as desired.
- Sign in to GitLab.com and copy the repo to my group.
- Set up my SSH key so I can easily commit updates.
- Commit a new .gitlab-ci.yml file that I found online for HTML:
pages: stage: deploy script: - mkdir .public - cp -r * .public - mv .public public artifacts: paths: - public only: - master
This auto-runs whenever there is a new commit and builds the site from ‘master’.
- Move all content files (e.g. css and html files) to ‘/public’ to make it consistent with the new GitLab CI/CD just configured.
- Add ‘www.corvae.com’ and ‘corvae.com’ new domains to the repo in my repo Settings > Pages:
- Configure my DNS changes. I happen to use NameCheap.
- Remove the incumbent CNAME DNS Records (I also removed from the repo the CNAME file that GitHub looks for)
- Add two A Records (same IP Address for all GitLab Pages):
- Add two TXT Records (‘@’ and ‘www’ hosts again) for both ‘www.corvae.com’ and ‘corvae.com’ as copied from the keys given in Settings > Pages (this is specific to your repo domains you added).Getting this to work was the only “struggle” and it prompted me to write this basic tutorial. What I was missing was a solid understanding of what I was configuring in the DNS settings that are entailed in this step.
- Go to the domains and check for verification for both domains. If they are not verified, it won’t work.