Overview: a simple workflow

Publishing an R (R Core Team 2017) bookdown (Xie 2017) website with GitLab Pages is as easy as:

  • hosting a repository on GitLab
  • adding a configuration file to the project

Host a project on GitLab

As GitHub, GitLab is a web-based Git repository manager. Creating a new project on GitLab is fairly intuitive for GitHub users. GitLab users can create unlimitate private projects for free (see here).

GitLab also offers a continuous integration service (GitLab CI) and a static websites hosting service (GitLab Pages) in its free plan.1
These features are also present in the open source software GitLab Community Edition (CE).

Add a GitLab CI configuration file

Add the following .gitlab-ci.yml file in the root of the project:

image: rocker/verse:3.4.1

  stage: deploy
  - Rscript -e "bookdown::render_book('index.Rmd', 'all', output_dir = 'public')"
    - public
  - master

For explanations, see section 1.1.

See the result

When the CI job is done, the website is served on GitLab Pages.
CI jobs status can be found in CI / CD menu > Jobs. An example, here.
The address of the GitLab Pages project can be found in Settings > Pages. An example, here.


R Core Team. 2017. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.

Xie, Yihui. 2017. Bookdown: Authoring Books and Technical Documents with R Markdown. https://CRAN.R-project.org/package=bookdown.

  1. CI pipelines are limited to 2,000 minutes per month