This blog is deployed using Gitlab pages, which is really easy to setup. In order to redirect to the blog from my domain hosted on OVH there was some configuration involved.
Create a .gitlab-ci.yml file at the root of your project, and add the following code to automatically deploy your Hugo website at every merge to the master branch.
# All available Hugo versions are listed here: https://gitlab.com/pages/hugo/container_registry image: registry.gitlab.com/pages/hugo:latest stages: - build variables: GIT_SUBMODULE_STRATEGY: recursive pages: stage: build script: - hugo artifacts: paths: - public only: - master
If your project is private (or internal), you may have to open the visibility for Gitlab pages
In Settings > General > Visibility, project features, permissions, the Pages feature should be enabled and set to everyone
- Click on new pages domain
- Set the domain field to your domain name, for instance “www.nicosauvage.fr”
- If your do not already have a certificate, leave Automatic certificate management using Let’s Encrypt checked
- Click on Create new domain
Create DNS record
As indicated in the Gitlab pages configuration page, we have to create a new DNS record to redirect our domain name to gitlab.io
The following steps will only work for a subdomain (for instance www.mysite.com). If you want to configure for a root domain, please see the documentation in the links at the bottom of this article.
- In your OVH dashboard, select the DNS zones tab, and click on Add an entry
- Select CNAME
- Set the same subdomain as defined in the Gitlab pages configurations (here www)
- Set the target as indicated by the Gitlab page (in my case Noki.gitlab.io.). Do not forget the period at the end.
- Click on next and validate
- Select TXT field type
- In subdomain, enter _gitlab-pages-verification-code.www
- Set value to gitlab-pages-verification-code=xxxxxxxxxxxxxxxxxxxxxxxxx
- In your Gitlab page configuration,
- Wait (a few minutes later, or hours)
- Click on the arrow next to “Unverified” (retry verification), the status should switch to “verified”