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.

Gitlab configuration

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

Gitlab Pages

  1. Click on new pages domain
  2. Set the domain field to your domain name, for instance “www.nicosauvage.fr
  3. If your do not already have a certificate, leave Automatic certificate management using Let’s Encrypt checked
  4. Click on Create new domain

Gitlab Pages configuration

OVH configuration

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.

  1. In your OVH dashboard, select the DNS zones tab, and click on Add an entry
  2. Select CNAME
  3. Set the same subdomain as defined in the Gitlab pages configurations (here www)
  4. Set the target as indicated by the Gitlab page (in my case Noki.gitlab.io.). Do not forget the period at the end.
  5. Click on next and validate

Verify ownership

  1. Select TXT field type
  2. In subdomain, enter _gitlab-pages-verification-code.www
  3. Set value to gitlab-pages-verification-code=xxxxxxxxxxxxxxxxxxxxxxxxx
  4. In your Gitlab page configuration,
  5. Wait (a few minutes later, or hours)
  6. Click on the arrow next to “Unverified” (retry verification), the status should switch to “verified”

OVH DNS configuration

Links

https://docs.gitlab.com/ee/user/project/pages/custom_domains_ssl_tls_certification/