Gitlab Page

Your website looks amazing on your computer + you know how git works? Awesome, let’s make the whole world knows how great your website (and you) is!

git push to Gitlab (remote repository)

Currently, the remote server of your local repository is https://github.com/wowchemy/starter-academic.git. You can see it by typing

git remote -v
> origin	https://github.com/wowchemy/starter-academic.git (fetch)
> origin	https://github.com/wowchemy/starter-academic.git (push)

We obviously want to change that.

Prepare the server

First, create an empty repository in your Gitlab’s account. On the interface, click on New Project (top right) and then create a blank project. The important point here is that the name of project matters a lot, you must name it using Gitlab page convention.

GitLab server Name of the project Website URL
Gitlab.com username.gitlab.io http(s)://username.gitlab.io
PLMLab.math.cnrs.fr username.pages.math.cnrs.fr http(s)://username.pages.math.cnrs.fr

Change the remote url

When your repository has been created, and in its main page, click on “clone” and copy/paste the “clone with ssh” line (you can use https but it slower and you have to ). It should be something like

# If PLMLAB
git@plmlab.math.cnrs.fr:username/username.pages.math.cnrs.fr.git
# else if Gitlab.com
git@gitlab.com:username/username.gitlab.io.git

Back on the git repository, at the root of it, change the url of your remote and then push to your repo:

git remote set-url origin git@plmlab.math.cnrs.fr:username/username.pages.math.cnrs.fr.git
git push origin master

git might be unhappy and asks you to push using a different command: please do what it asks you to do, for example it can be the following command:

git push --set-upstream origin master

After refreshing your gitlab page on your browser, you should see your repository: the files, the name of last commit, …

Gitlab Page: Continuous Deployment (CD)

Gitlab CI (Continuous Integration)

Your website is almost ready, you just need to explain Gitlab that it must build your website each times you push changes:

  1. Depending on your webserver, download or copy/past the right .gitlab-ci.yml and place it at the root of your folder (see the next remark):
  2. In your Gitlab/PLMLab account and in the project of your website: SettingsGeneral, expand the Visibility, project features, permissions. Enable Page access control to everyone (do not forget to save changes!)
  3. Do a dummy modification in your code, commit and push to activate the runner of Gitlab
About the image in the .gitlab-ci.yml file. An image refers here to a Docker image which is, to simplify, a minimalistic Linux operating system with hugo. So basically, when pushing modification to your code, gitlab downloads a Docker image and rebuilds the website using hugo.

Please do not forget to set the baseurl parameter in the config file! For the PLM, it has the following form: https://username.pages.math.cnrs.fr/.

It also seems that some file are not called using HTTPS. Without knowing why, setting the baseurl when calling Hugo seems to fix it:

hugo --baseURL="https://mywebsite/"

If everything works fine, you should be able to access your website at https://username.pages.math.cnrs.fr on your browser after, say, 5 to 10 minutes. If you did not received an error email and if your website is still inaccessible, you should try to

  • Refresh your browser multiple times
  • Clear the cache of your browser
  • Try another browser

This is because it takes time for a new website to be “known”.

Checking the process

You can check the process (pipeline and jobs) in your Gitlab’s interface in CI/CDJobs (or directly at https://plmlab.math.cnrs.fr/username/username.pages.math.cnrs.fr/-/jobs)

Set a SSH key to login without password

Every time you push your repo, you must type your password. Boring, right? SSH keys are the tools you need: please have a look at the Gitlab documentation which provides clear explanation.

Précédent